configuration file for Web. xml
<!--Configure spring filter to solve lazy loading problems - <Filter> <Filter-name>Opensessioninviewfilter</Filter-name> <Filter-class>Org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</Filter-class> </Filter> <filter-mapping> <Filter-name>Opensessioninviewfilter</Filter-name> <Url-pattern>*.action</Url-pattern> </filter-mapping> <!--Configuring the primary filter for STRUTS2 - <Filter> <Filter-name>Struts2</Filter-name> <Filter-class>Org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</Filter-class> </Filter> <filter-mapping> <Filter-name>Struts2</Filter-name> <Url-pattern>/*</Url-pattern> </filter-mapping>
Note: Be sure to configure it on top of the struts filter, otherwise it will not work
Use of Opensessioninview mode may cause memory and database connectivity issues
Due to the use of Opensessioninview mode, the session life cycle is longer. While solving the problem of lazy load, the problem is Hibernate's first level cache, that is, the session level of the cache life cycle will become very long, if the service layer in large batches of data operations, in fact, the data will be in the cache to retain a copy, This is very memory-intensive. There is a database connection problem, the reason is that because the database connection is tied with the session, so, connection will not be released in a timely manner. Therefore, when the system is very busy, and the computational volume is very large, the number of connections to the data connection pool will not be enough
Workarounds for lazy loading exceptions in SSH