Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.2.6
Code between sessionFactory.openSession() and session.close():
Code:
List<OrderReport> result = new ArrayList<OrderReport>();
Session session = HibernateUtil.getSession();
Transaction tx = null;
try {
tx = session.beginTransaction();
enableFilters(session);
result = session.createQuery(
"select distinct report from OrderReport as report " + "inner join fetch report.order ord "
+ "left join fetch ord.employee " + "left join fetch ord.customer "
+ "left join fetch ord.coWorkers "
+ "left join fetch report.actions "
+ "where ord.employee.id = :employeeId or :employeeId is null or :employeeId = 0").setParameter("employeeId", filterEmployee).list();
tx.commit();
Full stack trace of any exception that occurs: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:96)
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.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
Name and version of the database you are using:Postgresql 8.3
I understand the reason: two collections fetching fails:
Code:
"left join fetch ord.coWorkers "
+ "left join fetch report.actions "
But from the point of sql, which should have been generated I cannot understand, why it is impossible to join fetch two collections...