Bringing military-grade cybersecurity solutions to the enterprise and critical systems.
Telephone: 310.356.7869

HibernateException: cannot simultaneously fetch multiple bags

Category: ExceptionOfTheDay

9:29 AM, Mon, Aug 20 2007

You're doing everything the EJB 3 Way, meaning you are using persistent objects with collections. Everything is fine until you deploy and get today's Exception of the Day:

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)
                

This is due to a bug. The solution: You can have at most one @OneToMany(fetch=FetchType.EAGER) relationship in your entity. Remove the fetch=FetchType.EAGER attributes on all but one of the @OneToMany annotations in the entity.