if you store a hibernate object in session ( as a model object or a property of the component ) and access it in another request you will get the lazy load exception because that object is no longer connected to the session that loaded it.

to avoid this you can use detachable models that load the object whenever it is requested and only stores the id in session.

-Igor


On 2/17/06, Mark Derricutt <[EMAIL PROTECTED]> wrote:
On 2/18/06, Al Maw <[EMAIL PROTECTED]> wrote:

Spring contains an OpenSessionInViewFilter for Hibernate (which is a
standard Servlet API ServletFilter). This will open a single session at
the beginning of each request and close it when the request ends. You
should be hooking all this up to a database connection pool to make it
efficient.

Is there anything magic one needs to do for this?  I've tried adding this to two of my projects but I still seem to always get my lazy loading problems.  In my web.xml for my wicket app I had:

        <filter>
            <filter-name>openSessionInView</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>openSessionInView</filter-name>
            <url-pattern>/app/*</url-pattern>
        </filter-mapping>

Is this -all- I need?  Spring is being initialized with:

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

in my web.xml ( not sure if that matters? ).

--
i like my video games - mamma said they are gonna melt my brains
i like my video games - i don't care what daddy said; they're my reality
  - henning pauly

Reply via email to