I'm using Hibernate 3.2 in a JEE5 environment as my JPA provider. Unfortunately I have a recurring timer that looks up entities that have two bi-directional OneToMany mappings.
I was using TopLink Essentials and was hoping to make a smooth transition to Hibernate but it looks as if you can't have more then one OneToMany mapping with fetch=FetchType.EAGER set.
Code:
@OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.EAGER, mappedBy = "owningILDA")
I tried setting one to be LAZY but then I end up getting:
Code:
Caused by: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of ro
le: ejb.entity.ILDAEntityBean.ilda15MinUpdates, no session or session was
closed
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(Ab
stractPersistentCollection.java:358)
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfN
otConnected(AbstractPersistentCollection.java:350)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollec
tion.java:343)
at org.hibernate.collection.AbstractPersistentCollection.write(AbstractPersistentCollection.
java:183)
at org.hibernate.collection.PersistentBag.add(PersistentBag.java:274)
Is there another way around this besides switching back to TopLink Essentials which doesn't result in this problem?