Solution to the exception in SSH lazy loading; solution to ssh Loading

Source: Internet
Author: User

Solution to the exception in SSH lazy loading; solution to ssh Loading

 

Web. xml configuration file

<! -- Configure the Spring filter to solve the problem of lazy loading --> <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> <! -- Configure the master filter of Struts2 --> <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: It must be configured on the struts filter; otherwise, it will not work.

 

The OpenSessionInView mode may cause memory and database connection problems.
Because the OpenSessionInView mode is used, the Session lifecycle becomes longer. Although the Lazy Load problem is solved, the problem is that the first-level cache of Hibernate, that is, the lifecycle of the Session-level cache will become very long, if you perform a large volume of data operations on the Service layer, the data will actually be kept in the cache, which is very memory-consuming. There is also a database Connection problem because the Connection of the database is bound with the Session, so the Connection will not be released in time. Therefore, when the system is busy and the computing workload is very large, the number of connections in the data connection pool is insufficient.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.