I initialize lazy relations by calling loadLazyRelations method, in which I initialize all relations from entity using isEmpty() method:
public void loadLazyRelation() {
relation1.isEmpty();
relation2.isEmpty();
relation3.isEmpty();
relation4.isEmpty();
if(manyToOneObj != null) {
manyToOneObj.getLazyRelation().isEmpty();
manyToOneObj.getLazyRelation().isEmpty();
}
}
I call this method inside entity.getFull() from CRUD class. It works fine, it fully loads the entity and relations. I saved the initialized entity, but when I'm accessing it from the other method, I'm getting
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: relation, could not initialize proxy - no Session
Where is the problem?