This error occurs when you do a picture upload related entity save.
Related entity
@OneToMany (Mappedby = "ObjectSid", cascade = Cascadetype.all, Orphanremoval = True) @OrderBy ("Orderindex desc") Publ IC list<objectr2pic> getshoppagepics () {return shoppagepics; }
Controller
@Override @MetaData ("Save") public httpheaders dosave () { List<ObjectR2Pic> shopPagePics = Bindingentity.getshoppagepics (); if (! Collectionutils.isempty (shoppagepics)) { for (objectr2pic shoppagepic : shoppagepics) { shoppagepic.setobjectsid ( Bindingentity.getid ()); shoppagepic.setobjecttype (objectpictypeenum.shop_page_pic); } } return super.dosave (); }
The program is executed to
list<objectr2pic> shoppagepics = Bindingentity.getshoppagepics ();
Always get the picture information of the front end, so the next report is abnormal
Org.hibernate.LazyInitializationException:could not initialize Proxy-no Session
hibernate error caused by delayed initialization, at which point the proxy class instance or proxy collection is in Free State, at which time he is initialized, the error will be reported. Some netizens put forward, set the fetch crawl strategy lazy lazy mode is true, but also some netizens proposed such settings for memory, and performance unfriendly.
WORKAROUND: After careful investigation of S2JH's parent class, the original @S2JH has resolved the problem, which is pre-initialized lazy collection before use.
Append to Controller:
@Override protected void setupdetachedbindingentity (Long id) {bindingentity = Getentityservice (). Finddetachedon E (ID, "shoppagepics"); }
The persistent understanding of the individual hibernate is still not in place, if there is an expert to see, hope to be in the comment area pointing twos. For the shallow point of the article, please criticize it a lot.
S2JH Hibernate Lazy Crawl Strategy--could not initialize ProX