-->
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: Exception Hydrating entity with PersistentEnumTypes
PostPosted: Fri Feb 06, 2004 2:45 pm 
Newbie

Joined: Fri Feb 06, 2004 1:37 pm
Posts: 9
I have an object that I am persisting that has 2 PersistentEnum types properties. The object is created and the row is successfully inserted in the db, but when it is hydrated I am getting the following exception:

17:32:10,185 DEBUG [SessionFactoryImpl] - preparing statement
17:32:10,185 DEBUG [StringType] - binding '4028814efa8bb16f00fa8bb1c1230002' to parameter: 1
17:32:10,185 DEBUG [Loader] - processing result set
17:32:10,185 DEBUG [Loader] - result row: 4028814efa8bb16f00fa8bb1c1230002
17:32:10,185 DEBUG [Loader] - Initializing object from ResultSet: 4028814efa8bb16f00fa8bb1c1230002
17:32:10,185 DEBUG [Loader] - Hydrating entity: com.cougaarsoftware.core.message.assets.RegisteredAlertPGImpl#4028814efa8bb16f00fa8bb1c1230002
17:32:10,185 DEBUG [StringType] - returning null as column: alert_cl2_
17:32:10,185 DEBUG [StringType] - returning null as column: alert_id
17:32:10,185 DEBUG [BatcherImpl] - done closing: 0 open PreparedStatements, 0 open ResultSets
17:32:10,195 DEBUG [SessionFactoryImpl] - closing statement
java.lang.NullPointerException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.sf.hibernate.type.PersistentEnumType.getInstance(PersistentEnumType.java:53)
at net.sf.hibernate.type.PersistentEnumType.get(PersistentEnumType.java:47)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:59)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:51)
at net.sf.hibernate.type.AbstractType.hydrate(AbstractType.java:66)
at net.sf.hibernate.loader.Loader.hydrate(Loader.java:419)
at net.sf.hibernate.loader.Loader.loadFromResultSet(Loader.java:373)
at net.sf.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:342)
at net.sf.hibernate.loader.Loader.getRow(Loader.java:281)
at net.sf.hibernate.loader.Loader.doFind(Loader.java:159)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:587)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:42)
at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:396)
at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:1889)
at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1757)
at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1716)
at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:62)
at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:1959)
at net.sf.hibernate.loader.Loader.doFind(Loader.java:196)
at net.sf.hibernate.loader.Loader.find(Loader.java:620)
at net.sf.hibernate.hql.QueryTranslator.find(QueryTranslator.java:928)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1343)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1322)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1314)
at com.cougaarsoftware.core.persistence.DatabaseServiceImpl.query(DatabaseServiceImpl.java:302)
[SNIP]
17:32:10,205 DEBUG [SessionImpl] - closing session
17:32:10,205 DEBUG [SessionImpl] - disconnecting session
17:32:10,205 DEBUG [DriverManagerConnectionProvider] - returning connection to pool, pool size: 1
17:32:10,205 DEBUG [SessionImpl] - transaction completion


Here is a section of my mapping file:
Code:
   <!--RegisteredAlertPG-->
   <class name="com.cougaarsoftware.core.message.assets.RegisteredAlertPGImpl" table="REGISTERED_ALERT_PG">
      <id name="id" column="id" type="java.lang.String">
         <generator class="uuid.hex"/>
      </id>
      <property name="alertclass" column="alert_class" type="java.lang.String"/>
      <property name="alertId" column="alert_id" type="java.lang.String"/>
      <property name="priority" column="priority" type="com.cougaarsoftware.core.domain.ldm.alert.request.AlertPriority"/>
      <property name="type" column="type" type="com.cougaarsoftware.core.domain.ldm.alert.request.AlertType"/>
      <property name="status" column="status" type="java.lang.String"/>
      <property name="assigned" column="assigned" type="java.lang.String"/>
      <bag name="actions" cascade="all">
           <key column="registered_alert_id"/>
           <one-to-many class="com.cougaarsoftware.core.message.assets.RegisteredAction"/>
        </bag>
     </class>


I have properly implemented toInt() and fromInt() in my PersistentEnum implementations. I am currently using Hibernate 2.0.3, but I have gotten the same results with 2.1.2. Stepping through the debugger, I can see that the Method.invoke() call in PersistentEnumType:53 is to AlertType.fromInt() with code=3.

I'm using j2sdk1.4.2 on Windows.

Any help is greatly appreciated.


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.