-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Annotations mapping and Enumeration uses wrong value
PostPosted: Tue Nov 04, 2008 10:24 am 
Newbie

Joined: Tue Aug 07, 2007 3:19 am
Posts: 5
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.