-->
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.  [ 2 posts ] 
Author Message
 Post subject: Understanding : cannot simultaneously fetch multiple bags
PostPosted: Sun Feb 15, 2009 6:15 am 
Newbie

Joined: Sat Feb 23, 2008 4:09 pm
Posts: 3
I was reading up on this exception:

Code:
org.hibernate.HibernateException: cannot simultaneously fetch multiple bags


And I now understand why this is:

http://www.jroller.com/eyallupu/entry/hibernate_exception_simultaneously_fetch_multiple

However, if you take Eyal Lupu his example, you'll see that indeed the join duplicated the "child2-1" entry (while parent-1 only has one child2-1 relation).

Now, the instance loaded in memory will have two times the same reference (so the list will contain two entries which are ==).
Second, the two entries all have the same primary key (id).

My question is; why is it that hibernte cannot determine that there is only one cild2-1 entry?
If it used a 'distinct root entity projection' for example it would only retrieve one object...

Second, the solution is to add an index column.
But this is not really different from having the id's on the table in the first place no?
I don't understand why adding an index column solves this problem why there is allready a column that can indicate the uniqueness of a row (the primary key).
The index column is abused here for uniqueness instead of order.

So I do understand that it becomes more difficult to filter out the duplicates here, but why can't it be done without the id column?


Top
 Profile  
 
 Post subject: Re: Understanding : cannot simultaneously fetch multiple bag
PostPosted: Mon Feb 16, 2009 7:49 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
errorken wrote:
My question is; why is it that hibernte cannot determine that there is only one cild2-1 entry?
(...)
So I do understand that it becomes more difficult to filter out the duplicates here, but why can't it be done without the id column?

Actually filtering out duplicates can be done by hibernate and it is done, if you use for example sets instead of bags.

By definition, bags can contain duplicate entries, so it would be wrong if hibernate filtered them out.

_________________
-----------------
Need advanced help? http://www.viada.eu


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.