Announcement Announcement Module
Collapse
No announcement yet.
Could not initialize proxy - no Session Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Could not initialize proxy - no Session

    I have been struggling with this for a whlle. I have the following HQL:

    Code:
    SELECT prosocUser FROM ProsocUser AS prosocUser LEFT JOIN FETCH prosocUser.prosocPermissions WHERE prosocUser.userId = :userId
    and it seems to work OK (I think). When I try and access the prosocPermissions objects using:

    Code:
    prosocUser.getProsocPermissions();
    I get the error:

    Code:
    org.hibernate.LazyInitializationException: could not initialize proxy - no Session
    I know this is being thrown because the hibernate session has been closed but I can't figure out the solution to it. I am using:

    Code:
    sessionFactory.getCurrentSession()
    and I think that means that the session is closed before processing gets to the view stage which is where I am trying to access the hibernate proxy object. I have however tried to use:

    Code:
    org.hibernate.Hibernate.initialize(prosocUser.getProsocPermissions());
    but to no effect.

    Can anyone help me out?
    Last edited by klogger; Apr 18th, 2009, 04:59 PM.

  • #2
    I got it working as soon as I woke up this morning. I had been getting confused with hibernate in general and had simplified my query in order to understand things better. Once I got the query correct I hadn't un-simplified it. It needed an additional JOIN to make it work.

    Comment

    Working...
    X