Hi All,
I've been looking around the net to no avail. I'm pretty sure im missing something simple here. I have a field in db, that is of type int. I'm trying to properly map, using annotations the enum property.
Code:
@Entity
@Table(name = "MyTable")
public class myClass implements Serializable {
@Id
@Column(name = "Id", nullable = false)
private int id;
@Column(name="enumFieldId")
private MyEnumType enumtype;
/* getters & setters */
}
public enum MyEnumType {
ENUM_1 (1),
ENUM_2 (2);
private int value;
private MyEnumType(int value){
this.value = value;
}
public int getValue () {
return this.id;
}
public static MyEnumType fromValue (int value){
//returns the one coresponding to id
}
}
if from the the above i try to retrieve te DepositType i get
java.lang.IllegalArgumentException: Unknown ordinal value for enum class com.test.enums.MyEnumType: 23
I have the value Enum_X (23) but i dont have 23 items in the enum listing.
Any thoughts on how i can fix this?
Thanks
Nick