-->
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: Problems with onPreInsert, onPreUpdate
PostPosted: Tue Dec 06, 2005 12:57 am 
Beginner
Beginner

Joined: Fri Nov 04, 2005 3:51 pm
Posts: 32
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.1 release candidate 3

Hi,
Whenever an object of a particular class is updated, I need to update a property on each member of one of its collection properties as well.
I'm trying to implement this using Hibernate events. I've tried pre & post update events, and nothing seems to let me do this.

In particular, in onPreUpdate(), if I try to iterate through any collection properties on the event entity, it bombs after trying to do the update.

This is ok:
Code:
entity.getCollectionA();


This results in an error after the actual update is attempted by Hibernate (not immediately):
Code:
entity.getCollectionA().iterator();



Code:
     org.hibernate.AssertionFailure: an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
org.hibernate.AssertionFailure: collection was not processed by flush()
   at org.hibernate.engine.CollectionEntry.postFlush(CollectionEntry.java:183)
   at org.hibernate.event.def.AbstractFlushingEventListener.postFlush(AbstractFlushingEventListener.java:328)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:28)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:908)



The above error only happens if the collection is lazy. If it is not lazy, then I don't get any errors, but none of my modifcations to the property values are persisted.

Based on my reading from the docs and forum, it looks like this may be a session management issue. I'm using the Threadlocal method from the HibernateUtil example. I've also tried creating a temporary session as per the example in Hibernate In Action.

I've seen a few simarly questions on this in the forums, but no real answers.
Can anyone some idea on where to start looking for a solution?


Thank you


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.