-->
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: Some interesting findings about <many-to-any>
PostPosted: Wed Sep 21, 2005 7:58 am 
Newbie

Joined: Wed Feb 25, 2004 5:28 pm
Posts: 15
Hibernate version: 3

We use <many-to-any> for collections of interfaces.

Before adding en entry to a <many-to-any> collection, all entries in the collection must be loaded/materialised first, else
at the post-flush stage, en exception throws:
ERROR AssertionFailure:22 - 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:144)


My explanantion to this:
In the event of a add to a many-to-many relation, Hibernate delete all entries in the phsyical table implementation,
then insert the entire new collection.
This is all well in a normal many-to-many bag, but when it comes to the many-to-any bag: while adding the entries
for the entire collection, Hibernate loads/materialises each and every object. Probably because on the any-end, the
class and key are specified, at the same time, "session" ,perhaps, is not
aware of all the entries in the collection. Then an exception at postflush stage: collection not processed.

My solution is simply to load/materialise each and every entry in the collection using session.get(), before an add.

Any comments anyone?
/Kwan

ps, cascade parameter and Hibernate.initialize() only initialize the proxies, so I use session.get() to get loading/materialization. Any shortcut here ?


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.