-->
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: @ManyToOne x 2 = "cannot fetch simultaneous bags"
PostPosted: Fri Jun 19, 2009 10:05 am 
Newbie

Joined: Tue Jul 27, 2004 1:33 pm
Posts: 18
Location: South Africa
Hi all,

I know that one has to use Set or annotations when a JPA entity has two or more collections or @OneToMany relationships to get the collections to populate on eager loading. However I am getting this error on one of my entities that has two @ManyToOne relationships. It has worked without problems for hundreds of other entity classes that I have created in the past. The only difference is that this time I am using a pre-existing data base so need to map the objects to the names they have in the database, ie the database naming convention is different to the default for hibernate.

I have setup my class as follows:


@ManyToOne
@JoinColumn(name="analysisgid")
private AnalysisGroup analysisGroup;

@ManyToOne
@JoinColumn(name="customerid")
private Organisation customer;

When running my unit tests I get the "simultaneous bag" error.


Caused by: org.hibernate.HibernateException: cannot simultaneously fetch multiple bags
at org.hibernate.loader.BasicLoader.postInstantiate(BasicLoader.java:66)
at org.hibernate.loader.entity.EntityLoader.<init>(EntityLoader.java:75)
at org.hibernate.loader.entity.EntityLoader.<init>(EntityLoader.java:43)
at org.hibernate.loader.entity.EntityLoader.<init>(EntityLoader.java:33)
at org.hibernate.loader.entity.BatchingEntityLoader.createBatchingEntityLoader(BatchingEntityLoader.java:103)
at org.hibernate.persister.entity.AbstractEntityPersister.createEntityLoader(AbstractEntityPersister.java:1752)
at org.hibernate.persister.entity.AbstractEntityPersister.createEntityLoader(AbstractEntityPersister.java:1756)
at org.hibernate.persister.entity.AbstractEntityPersister.createLoaders(AbstractEntityPersister.java:2989)
at org.hibernate.persister.entity.AbstractEntityPersister.postInstantiate(AbstractEntityPersister.java:2982)
at org.hibernate.persister.entity.SingleTableEntityPersister.postInstantiate(SingleTableEntityPersister.java:690)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:290)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)

Could it be that the error relates to another class? The error goes away if I take either one of the @ManyToOne mappings above out of the entity bean.

thanks

_________________
http://www.jumpingbean.co.za
http://www.cyberconnect.co.za
http://www.ip-pbx.co.za
http://www.learndrupal.co.za


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