Workarounds for lazy loading exceptions in SSH

Source: Internet
Author: User

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

Related Article

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.