we're facing a very confusing issue in our application which is designed as 3 tier application using * Spring-Data JPA (1.8.2.RELEASE), Hibernate (4.3.10.Final) in data layer * Spring managed Pojos (@Service beans) in service layer * Wicket (7.2.0) in GUI layer
I know and I'm aware of the problems that might arise when using JPA managed beans in GUI layer (Lazy loading, equals, hashcode etc). To get rid of that we use Wickets LoadableDetachableModels to reload every single entity during each request.
Now we have a page where the user can select an entity within a tree. Entity is encapsulated within a LoadableDetachableModel as mentioned. This entity has a 1:n relation to another entity. When selecting the entity via tree, the 1:n relation is beeing accessed leading to the well known org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.isb.bppm.wm.model.Product.children, could not initialize proxy - no Session
exception.
This is very confusing, since this only occurs when configuring DB2 as database. For local development we're using in memory apache derby where the same code doesn't lead to the mentioned exception. My analysis so far leaves the database as only difference between the two configurations. Let me further mention, that we use Springs OpenEntityManagerInViewFilter for every request, so the situation where no session is open should never occur.
Has anybody of you faced similar issues and can give us a hint what might got wrong?