What annotation is used in the ORMLite mapping for Enum as Foreign?

0

I have the Customer class and the Enum PetsEstimation where a customer can have 1 or more pets. It would look like this:

@DatabaseTable(tableName = "cliente")
public class Cliente{

@DatabaseField(generateId = true)
private Long id;

@DatabaseField
private String nome;

@????
List<AnimaisEstimacao> animais;

Enum AnimalsWarning

public enum AnimaisEstimacao{
GATO(0);
CACHORRO(1);
PASSARO(2);
OUTROS(3);
//implementacao
}

What would be the ORMLite annotation for the Enum AnimalsStimation present in the Client class?

    
asked by anonymous 17.04.2014 / 16:13

2 answers

0

Some time ago I made a similar code. Try to resolve this:

@DatabaseTable(tableName = "cliente")
public class Cliente{

@DatabaseField(generateId = true)
private Long id;

@DatabaseField
private String nome;

@ForeignCollectionField(foreign = true, eager = true)
Collection<AnimaisEstimacaoCliente> animais;

So you create a class, for example, "AnimalsCustomerName" with the fields "AnimalEstimation" and "Client" for the relationship to exist. This class must be a representation of a table in the database.

@DatabaseTable(tableName = "animais_estimacao_cliente")
    public class AnimaisEstimacaoCliente{

    @DatabaseField(generateId = true)
    private Long id;

    @ForeignCollectionField(foreign = true )
    private Cliente cliente;


    @DatabaseField(dataType = DataType.ENUM_INT)
    private AnimalEstimacao animal;
}

More information is available at the links:

17.04.2014 / 18:53
0

According to the ORMLite documentation it would look like this:

@DatabaseTable(tableName = "cliente")
public class Cliente{

@DatabaseField(generateId = true)
private Long id;

@DatabaseField
private String nome;

@DatabaseField(dataType = DataType.ENUM_INTEGER)
List<AnimaisEstimacao> animais;
    
17.04.2014 / 16:33