Error page Tips
Could not initialize Proxy-no Session
Control Desk
Org.hibernate.LazyInitializationException:could not initialize Proxy-no Session
Illness: This is a lazy use of the exception, using a late load, in the session (Hibernate session), closed after using the object's non-loaded variables, that is, the session is closed, not saved in memory, and then you use, Causes the exception.
Q: I get an object with get, and when the JSP page expresses its instance variable with El, it throws the exception, but it doesn't appear when the application is tested.
A: Presumably the instance variable is hibernate-loaded, and it is possible that hibernate itself is loading the instance variable in the form of load.
Workaround:
Method 1. Using Opensessioninview
Method 2. To disable the delay loading of this class
List=query.list (); for (Object object:list)
Hibernate.initialize (((Deliver) object). Getplnbill ());//deliver is a composite object with attributes referenced in Plnbill
OR
RESULTEXCHANGERATEPOJO.GETDOLLARRMB ();//In its instance variable DOLLARRMB the session is not closed before closing, actually loading it into memory. (I just want to save the value in memory before you can use it before you close the session)
The result: Sure enough, the page is displayed normally.
Summary: The reason is that Hibernate's session has been closed and the collection has not been initialized. In hibernate: Hibernate3 supports lazy loading by default (lazy= "proxy" We can think of as true), Hibernate2 load immediately (lazy= "false").
In Hibernate3, all the lazy properties in the Entity settings file (User.hbm.xml) are set to True by default, which is when the class is not called, delaying loading, which causes the above to occur, and setting the Lzay property to False in the configuration file.
----------------------------------------------------------------
Reason:
<may-to-one>or<one-to-may> 's Lazy property defaults to: Lazy = "proxy"
Fix:<many-to-one> & <set> set lazy= "false"
If not, according to their own needs, after my careful troubleshooting placed on the set one end, it is placed on the <many-to-one> end.
Lazy Load Exception org.hibernate.LazyInitializationException:could not initialize Proxy-no Session