[jboss-user] [EJB 3.0] - 2 FETCH Joins in 1 query

Juergen.Zimmermann do-not-reply at jboss.com
Fri Nov 17 09:48:28 EST 2006


I'm using JBoss 4.0.5GA with EJB3 annotations. I want to read objects of class Customer and also fetch their orders plus the shipments of these orders. I tried this named query:
SELECT DISTINCT c
  | FROM Customer c
  |    LEFT JOIN FETCH c.orders o
  |    LEFT JOIN FETCH o.shipments
  | WHERE c.lastname = :lastname
  | 

However, I get the following exception:
org.hibernate.HibernateException: cannot simultaneously fetch multiple bags
  | 	at org.hibernate.loader.BasicLoader.postInstantiate(BasicLoader.java:66)
  | 	at org.hibernate.loader.hql.QueryLoader.<init>(QueryLoader.java:101)
  | 	at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:181)
  | 	at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
  | 	at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
  | 	at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
  | 	at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
  | 	at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:400)
  | 	at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:351)
  | 	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1218)
  | 	at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:688)

What's going wrong? Any hint is appreciated!

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3986844#3986844

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3986844



More information about the jboss-user mailing list