-->
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: saveOrUpdateCopy and LazyInitializationException
PostPosted: Thu Mar 17, 2005 10:42 pm 
Newbie

Joined: Thu Mar 17, 2005 10:19 pm
Posts: 1
I have a parent class with set of one-to-many children class mapping:

Code:
<class name="parentClass" table="parent_table" optimistic-lock="version">
   ...
  <set name="children" lazy="true" inverse="true" cascade="delete">
   <key>
     <column name="parentId" />
   </key>
   <one-to-many class="childClass" />
  </set>
</class>

When try to update the parent, I always get LazyInitializationException.

I need to keep a audit log of any changes make to parent's properties (excluding children property). I don't want to make the lazy="false" due to performance issue.

If use saveOrUpdate() or update() instead of saveOrUpdateCopy(object), i will not get the snapshot of previousState of parent class.

I try locked(object, LockMode.None) before calling saveOrUpdateCopy(object), but changes are not save to db.

For temparaly measure, I now used update(object). Inside the inerceptor.onFlushDirty(..) method, I add following code to get the previousState:


Code:
if (previousState == null)
{
Object original = session.get(entity.getClass(), session.getIdentifier(entity));
previousState = persister.getPropertyValues(original);
}



Any idea?



Code:


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.