Using Hibernate 3.3.1.GA
Hibernate-Annotations 3.4.0.GA
hibernate-commons-annotations 3.3.0.ga
Java Persistence API 1.0
I have mapped a table using Annotations and a field in that table using Enumeration.
The field is configured like this:
Code:
@Enumerated(EnumType.ORDINAL)
@Column(name = "CUST_AUTO_UPDATE", length = 1)
private CustAutoUpdate custAutoUpdate;
The Enum:
Code:
public enum CustAutoUpdate {
UPDATE_VALUE0 (0),
UPDATE_VALUE1 (1),
UPDATE_VALUE2 (2);
final int value;
CustAutoUpdate(int value){
this.value = value;
}
}
Stack trace:
Quote:
java.lang.IllegalArgumentException: Unknown name value for enum class no.bbs.bkad.domain.bankkunde.KundeAutomatiskOppdatering: 0
at org.hibernate.type.EnumType.nullSafeGet(EnumType.java:113)
at org.hibernate.type.CustomType.nullSafeGet(CustomType.java:128)
at org.hibernate.type.AbstractType.hydrate(AbstractType.java:105)
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2124)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1404)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1332)
at org.hibernate.loader.Loader.getRow(Loader.java:1230)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:603)
at org.hibernate.loader.Loader.doQuery(Loader.java:724)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2228)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
at org.hibernate.loader.Loader.list(Loader.java:2120)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:118)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1596)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
The field should be store in the table as a value (0, 1 or 2). The database column CUST_AUTO_UPDATE is a number.