• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

OpenEntityManagerInView, yet closed session

 
Eric Nielsen
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to understand what could be closing my entityManager early. I'm using OpenEntityManagerInView and until today its worked as needed.

I've put a break point in the code and checked the variables inside the field whose access triggers the LazyInitializationException. The field in question is mapped by


It shows up in the debugger as a PersistentBag.
directlyAccessible, dirty, initialized, and initializing are all false
session is a nonNull SessionImp, session.closed = true and session.rootSession=null

I'm not seeing any errors in the logs (application, tomcat, nor postgresql).

I am not sure its relevant, but in case it is, the call stack reaching this point:
JSP calls to
1) user.getHeatSheets
2) ends up calling a constructor for HeatSheet
3) which calls Competition.getEventsFor
4) which references the events collection

1) user is stored in the session and is merged back with the current EntityManager (via a calling lock() on the underlying HibernateSession)
2) HeatSheet is not a mapped/persistentEntity, but everything it references is
3) is where I set the breakpoint and reported on the values above
4) is where the exception is thrown

Digging a little deeper, it looks like the problem is first surfacing in a relationship entity.
User has a getAttendedCompetitions() method that does

Ie building a simple set of entities on the far side of a m:m mapping table/entity (the mapping entity has extra attributes, which is why its mapped as the explicit join entity rather than using a simple @ManyToMany.

The persistent collections on the return from ca.getCompetition() has their session set to closed... Any idea why?

[ July 20, 2008: Message edited by: Eric Nielsen ]
[ July 20, 2008: Message edited by: Eric Nielsen ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic