Hi!
i am getting a LazyInitializationException in class which implements ContainerRequestFilter and ContainerResponseFilter. In this class, i retrieve the entity using EntityManager.createQuery(query) which runs without problems and returns the entity. But then i call the method getSystem() on the entity, which throws this exception.
attribute system is as follows:
Code:
...
@ManyToMany(mappedBy = "identity", fetch = FetchType.LAZY)
private List<System> systems = new ArrayList<>();
...
public List<System> getSystems() {
return systems;
}
I am using Wildfly 8.1 with Hibernate 2.1 (i guess).
I dont get, why the entityManager returns the entity (which indicates, that the session must exist) and then calling the method getSystems throws LazyInitializationException: failed to lazily initialize a collection of role ...Entity.systems, could not initialize proxy - no Session. Is there a way to solve this? (other than using EAGER fetch type).
Thanks!