-->
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.  [ 6 posts ] 
Author Message
 Post subject: loadedState null when updateing an object
PostPosted: Fri Mar 11, 2005 8:58 am 
Newbie

Joined: Thu Jun 24, 2004 4:06 am
Posts: 9
Hibernate version: 3rc1

Mapping documents:
Code:
<hibernate-mapping package="com.reservit.plannit.data.bo.common">
   
   <class name="TextBO" table="text">
      <composite-id name="textID" class="TextID" unsaved-value="none">
           <key-property name="id" column="textid" type="long"/>
         <key-property name="langCode" column="langcode" type="string"/>
      </composite-id>
      <version name="version" type="integer" unsaved-value="null"/>
      <property name="text" column="value" type="string"/>
   </class>
   
</hibernate-mapping>

Code:
   <class name="CategoryBO" table="roomcategory">
      <id name="id" column="roomcategory" type="integer">
         <generator class="identity"/>
      </id>
      <version name="version" type="integer" unsaved-value="null"/>
      <map name="name" lazy="true" cascade="save-update" fetch="join">
         <key column="textid" property-ref="categoryNameId"/>
         <index column="langcode" type="string"/>
         <one-to-many class="com.reservit.plannit.data.bo.common.TextBO"/>
      </map>
</class>


Code between sessionFactory.openSession() and session.close():
Code:
getSession().saveOrUpdate(category);


Full stack trace of any exception that occurs:
Code:
java.lang.NullPointerException
   at org.hibernate.engine.EntityEntry.getLoadedValue(EntityEntry.java:141)
   at org.hibernate.type.CollectionType.getKeyOfOwner(CollectionType.java:269)
   at org.hibernate.engine.Collections.updateReachableCollection(Collections.java:105)
   at org.hibernate.event.def.FlushVisitor.processCollection(FlushVisitor.java:37)
   at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:81)
   at org.hibernate.event.def.AbstractVisitor.processValues(AbstractVisitor.java:43)
   at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:197)
   at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:190)
   at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:70)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:669)
   at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:293)
   at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
   at com.reservit.plannit.data.services.hibernate.HibernateManager.saveOrUpdateInNewTx(HibernateManager.java:340)
   at com.reservit.plannit.data.services.hibernate.CategoryManagerImpl.saveCategory(CategoryManagerImpl.java:138)
   at com.reservit.plannit.data.services.hibernate.CategoryManagerImpl.saveCategory(CategoryManagerImpl.java:116)
   at com.reservit.plannit.test.manager.CategoryManagerTest.save(CategoryManagerTest.java:92)
   at com.reservit.plannit.test.manager.CategoryManagerTest.testUpdate(CategoryManagerTest.java:82)
   at com.reservit.plannit.test.manager.CategoryManagerTest.main(CategoryManagerTest.java:197)


Name and version of the database you are using:
hsqldb

Debug level Hibernate log excerpt:
Code:
   public Object getLoadedValue(String propertyName) {
      return loadedState[
         ( (UniqueKeyLoadable) persister ).getPropertyIndex(propertyName)
      ];
   }

in debbug, i can pointed out that loadedState is null


This exception happend when i update a category object. Creation of a category with the same method dont failed.

The particularity of this object is that Category reference a TextBO object which use a composite key of a sequence number generated by my applicaiton when recquired and an ISO language code set by my application.

Please can somone tell me what have i done wrong?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 14, 2005 9:51 am 
Newbie

Joined: Thu Jun 24, 2004 4:06 am
Posts: 9
still need help please


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 14, 2005 11:16 am 
Newbie

Joined: Thu Jun 24, 2004 4:06 am
Posts: 9
i change my code to avoid using a composite key and the problem still happens.

i downgrade to hibernate beta 3 and 4b and still the same stacktrace.

is it a bug?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 14, 2005 12:53 pm 
Newbie

Joined: Thu Jun 24, 2004 4:06 am
Posts: 9
I think this problem is a bug when using property-ref in a many-to-one mapping.

Code:
      <map name="name" lazy="true" cascade="save-update" fetch="select">
         <key column="textid" property-ref="nameId"/>
         <index column="langcode" type="string"/>
         <one-to-many class="com.reservit.plannit.data.bo.common.TextBO"/>
      </map>

if i change this mapping using classic column
Code:
<map name="name" lazy="true" cascade="save-update">
         <key column="textid" foreign-key="nameid" />
         <index column="langcode" type="string"/>
         <one-to-many class="com.reservit.plannit.data.bo.common.TextBO"/>
      </map>

all runs well


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 15, 2005 9:03 am 
Newbie

Joined: Thu Jun 24, 2004 4:06 am
Posts: 9
using a foreign key was not a good idea: the inserted id in text table use the category id and not those setting in textBO object.

I must use a property ref to have good id inserted in DB
can some one from Hibernate team tell me what to do to avoid this nullpointer exception


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 30, 2005 8:47 am 
Beginner
Beginner

Joined: Wed Aug 27, 2003 7:53 am
Posts: 27
I had hit the same problem. I seriously think it's a bug. Reported here. Hope the hibernate team will find out what's this soon.

_________________
.Digital.Yearning.for.Networked.Assassination.and.Xenocide


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

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.