aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate: Why is bag semantic getting applied when I'm not using Lists? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate: Why is bag semantic getting applied when I Watch "Hibernate: Why is bag semantic getting applied when I New topic
Author

Hibernate: Why is bag semantic getting applied when I'm not using Lists?

Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
Hi,

Using Hibernate 3.3.2.ga.

I have a model with two OneToMany relationships. Whenever I try and load my session, I'm getting the "org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple bags" exception. From what I've read, this should not happen if I'm using Sets, which I am. My model code is below. Any help is appreciated, - Dave


Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

I had this problem. I believe it happens when both sides of a one to many are marked eager. Either that, or multiple classes pointing to a certain other class have multiple many associations marked as eagar. I bet if you made eagar associations lazy, the problem would go away. Any thoughts?
Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
Thanks for your reply, Cameron. I changed both associations in the included code from EAGER to LAZY but sadly this didn't heal the pain. Any other suggestions are appreciated, - Dave
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

I'm not sure.

Here's a good article on the topic:
Multiple Bag Fetch Exception In Hibernate

That's pretty much what I know and have experienced with this problem.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate: Why is bag semantic getting applied when I'm not using Lists?