-->
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: "cannot simultaneously fetch multiple bags" on Set
PostPosted: Wed May 24, 2006 1:43 am 
Beginner
Beginner

Joined: Thu Oct 16, 2003 7:25 pm
Posts: 38
Location: New York City
For previous references to my problem, check http://forum.hibernate.org/viewtopic.php?t=959478

I would really like to be able to have multiple sets declared to be fetched EAGERly in my POJOs, but whatever combination of annotations I use that would specify a non-lazy fetch, I keep getting the "cannot simultaneously fetch multiple bags" error. I do not wish to leave the sessions open, and I have made sure that there are sufficient unidirectional associations so that I don't wind up loading the "whole database" in a single POJO.

I really was depending on the @OneToMany and @ManyToMany EAGER fetching. All of my collections are defined as SortedSet or Lists with an @IndexColumn, and so, by definition, are not Bags, according to the documentation.

I have tried @Fetch(FetchMode.JOIN) and I have tried @LazyCollection(LazyCollectionOption.FALSE). Is there any working way to declare these collections not lazy? There must be a way around this issue, yes? I haven't been able to find an answer on the forum for two days, and none of my investigations have been very useful.

I believe that there may be an issue with this method found in org.hibernate.loader.BasicLoader.java:

Code:
   private boolean isBag(CollectionPersister collectionPersister) {
      return collectionPersister.getCollectionType().getClass().isAssignableFrom( BagType.class );
   }


Why would a BagType be assignable to a SortedSet? A Set should never be considered a Bag, yes? Something's off here, and my window is about to close on my project. Can someone help? Perhaps provide me with the annotations necessary to load these collections non-lazy?

Thanks.

Tom Harris


Top
 Profile  
 
 Post subject: Fixed... inverse side @ManyToMany missing @IndexColumn
PostPosted: Fri May 26, 2006 1:25 pm 
Beginner
Beginner

Joined: Thu Oct 16, 2003 7:25 pm
Posts: 38
Location: New York City
So, it turns out that the inverse side of a bi-directional @ManyToMany association requires that the same @IndexColumn be specified as the owning side. Once I had added those, the "multiple non-lazy bag" issue went away. Since the error doesn't specify which bag associations are involved, or even which Entity, it was very difficult to track down the issue. Also, none of the documentation mentions that the inverse should have the IndexColumn specified. Other annotations that specify columns, like in a join, are only on the owning side; the inverse usually just has the mapping reference. Hence, the confusion.

So, if you happen to get this "cannot simultaneously fetch multiple bags" error, make sure you don't have more than one non-lazy association that might be misinterpreted as a bag. Lists must have an @IndexColumn, and when expressing bidirectional @ManyToMany, be sure to include the @IndexColumn on both sides.

Hope this helps someone. I suggest adding a note in the annotation documentation regarding this.


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.