Today I encountered another error.
Org. hibernate. lazyinitializationexception-cocould not initialize proxy-the owning session was closed
I tested and found several solutions:
1. Change lazy = true to lazy = false.
2. If XXX. Load (class, ID) is used in the query, it is changed to XXX, get (class, ID)
3. Add the following content to the Web. xml file:
<Filter>
<Filter-Name> hibernatefilter </filter-Name>
<Filter-class> org. springframework. Orm. hibernate3.support. opensessioninviewfilter </filter-class>
<Init-param>
<Param-Name> singlesession </param-Name>
<Param-value> false </param-value>
</Init-param>
<! -- This -- <init-param> must be added. Otherwise, the error 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>
<Filter-mapping>
<Filter-Name> hibernatefilter </filter-Name>
<URL-pattern> *. MMG </url-pattern>
</Filter-mapping>