![]()
In my Web controller, I'm using a service that gets me User objects, like this:
on the next line, I'm using this object as a parameter to another method call:Code:bernard = system.getUser ("bernard");
in the body of that method, I'm doing the following:Code:boolean granted = system.checkPermission (null, "/", ResourceNames.contactPermissions, bernard, CREATE);
the call to iterator() however, causes the LazyInitializationException.Code:boolean checkPermission (...) { Collection groups = user.getGroups (); ... if (groups!=null) { for (Iterator it=groups.iterator(); it.hasNext(); ) }
When, on the other hand, I "re-initialize" the reference to the User object prior to the user.getGroups() call, like this:
...the exception isn't raised anymore.Code:List users = session.find ("from fractals.psychos.core.system.entity.User user WHERE user.username=? AND user.password=?", new Object [] {user.getUsername (), user.getPassword ()}, new net.sf.hibernate.type.Type [] {Hibernate.STRING, Hibernate.STRING}); user = (User) users.iterator ().next();
Looks like, two separated calls on a facade involve each a new Session...
It's been over a week now that I fight this problem: this is way too much for a framework that's supposed to simplify my life!
bernard


Reply With Quote