hibernate lazy loading failed

sponsored links
Concerned about the javaeye has been more than a year, but had no opportunity to write a log. Today, they wanted big cow jokes are not afraid of you wrote a log. Want to beginners strtus, hibernate, spring who have some help.

The lazy loading, I no longer introduced. I believe that if it used the hibernate will have a certain understanding of. The javaeye also saw a lot of similar problems. Here I need not repeat.

If there is a similar error, first check whether the web.xml to configure the following code:

<filter>   
        <filter-name>opensession</filter-name>   
        <filter-class>   
            org.springframework.orm.hibernate3.support.OpenSessionInViewFilter   
        </filter-class>   
            <init-param>      
            <param-name>singleSession</param-name>      
            <param-value>true</param-value>      
            </init-param>    
</filter>   
<filter-mapping>   
        <filter-name>opensession</filter-name>   
        <url-pattern>/*</url-pattern>   
</filter-mapping> 


Many people in the configuration of the above code, but problem is still there. This will be done the following analysis:

Each request, whether it has passed through a OpenSessionInViewFilter this filter. If they do not it, then your configuration is actually invalid. Therefore, I recommend this configuration to the web.xml to configure the first filter to avoid interference! The more I have been to a lot of people ask me, the problem ultimately lies in the place. In particular the inclusion of strtus later. Easily lead to such problems, such as the following configuration:

<!-- Struts filter -->
    <filter>
        <filter-name>struts2Filter</filter-name>
        <filterclass>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>struts2Filter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>


StrutsPrepareAndExecuteFilter configuration must OpenSessionInViewFilter after.

The reason is simple: StrutsPrepareAndExecuteFilter have all been blocked, OpenSessionInViewFilter will fail!
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of hibernate lazy loading failed

  • spring + hibernate + oracle9i to read and write CLOB

    Database-driven update classes12-9i.jar Hibernate modify the configuration of the following code <bean/> <bean Lazy-init="true"> <property name="nativeJdbcExtractor"> <ref local="nativejdbcExtractor"/>

  • Spring + Hibernate to use Glassfish Database Connection Pool

    applicationContext.xml file content <? xml version = "1.0" encoding = "UTF-8"?> <beans xmlns = " http://www.springframework.org/schema/beans " xmlns: xsi = " http://www.w3.org/2001/XMLSchema-instance " ...

  • Build flex + spring + blazeds + hibernate application

    Build flex + spring + blazeds + hibernate application First, set up the project blazeds 1, will blazeds.war extract to a directory, such as: myflex /; 2, set up java works were such as: MyFlex, in the orientation of selection create project from exis ...

  • Process migration from tomcat to websphere changes

    Process migration from tomcat to websphere changes Because customers use the web application server software used by different what tomcat5, tomcat6, websphere5.1, websphere6.1, weblogic8, and so on, and the software used inconsistent standards, ibm's

  • Spring2.0 + hibernate3.1 + log4j + mysql demo

    applicationContext.xml Non-attachment jar package, necessary friends can send an email to todd.liangt @ gmail.com

  • The level Hibernate cache

    Hibernate cache level: (1) a cache is very short and the session life cycle consistent, also known as session-level cache-level cache or transaction-level cache (2) Ways of Supporting level cache: get (); load (); iterator (); only entity object cach ...

  • spring struts2.0 hibernate bug killer 1

    exception There is no Action mapped for namespace / and action name checkLogin. - [Unknown location] com.opensymphony.xwork2.DefaultActionProxy.prepare (DefaultActionProxy.java: 186) org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy ...

blog comments powered by Disqus
Recent
Recent Entries
Tag Cloud
Random Entries