Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Dave Alvarado
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 436
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic