Hibernate throws this exception during SessionFactory creation:
org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple b
One good thing about @LazyCollection(LazyCollectionOption.FALSE)
is that several fields with this annotation can coexist while FetchType.EAGER
cannot, even in the situations where such coexistence is legit.
For example, an Order
may have a list of OrderGroup
(a short one) as well as a list of Promotions
(also short). @LazyCollection(LazyCollectionOption.FALSE)
can be used on both without causing LazyInitializationException
neither MultipleBagFetchException
.
In my case @Fetch
did solve my problem of MultipleBacFetchException
but then causes LazyInitializationException
, the infamous no Session
error.