-->
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.  [ 2 posts ] 
Author Message
 Post subject: Cannot simultaneously fetch multiple bags error
PostPosted: Sat Aug 02, 2008 4:18 am 
Beginner
Beginner

Joined: Wed Jul 30, 2008 8:43 am
Posts: 32
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...


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 02, 2008 5:58 pm 
Newbie

Joined: Mon Jun 16, 2008 1:15 pm
Posts: 15
Define your association as Set instead of Collection etc will get rid of this multi-bag thing for you. It is a hibernate bug that has been open for years.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

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.