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
|
|