環境 spring+hibernate3+struts 今天又碰到錯誤 failed to lazily initialize a collection of role: no session or session was closed 試驗了一下發現了幾個解決方法: 1、是把對應一對多的那兩個列lazy=true改爲lazy=false即可 2、對於查詢中如果用的是xxx.load(class,id)則改爲xxx,get(class,id) <filter> <init-param> <!--這個-- <init-param>一定要加不然很可能會報錯:org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly' marker from transaction definition <filter-mapping> |
failed to lazily initialize a collection of role:
大中小
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.