Results 1 to 2 of 2

Thread: Problem regarding OpenSessionInViewFilter

  1. #1
    Join Date
    Apr 2005
    Posts
    6

    Default Problem regarding OpenSessionInViewFilter

    Hi,
    I am using hibernate 2.1 with the spring framework. I use the following code in web.xml
    <filter>
    <filter-name>openSessionInViewFilter</filter-name>
    <filter-class>
    org.springframework.orm.hibernate.support.OpenSess ionInViewFilter
    </filter-class>
    <init-param>
    <param-name>sessionFactoryBeanName</param-name>
    <param-value>localSessionFactory</param-value>
    </init-param>
    <init-param>
    <param-name>singleSession</param-name>
    <param-value>true</param-value>
    </init-param>
    </filter>
    <filter-mapping>
    <filter-name>openSessionInViewFilter</filter-name>
    <url-pattern>action to forward to</url-pattern>
    </filter-mapping>

    I use hibernateTemplate to execute my queries. When I start my application, there is a session created by the filter and bound to the thread. The hibernate template seems to be creating another session and closes the session which is executing the query. This in turn is causing issues regarding lazy loading as the session does not seem to exist. Please look at the debug messages which show that a different session is created to run the query.

    2005-04-14 10:12:58,038 DEBUG org.springframework.orm.hibernate.support.OpenSess ionInViewFilter - Opening single Hibernate session in OpenSessionInViewFilter
    2005-04-14 10:13:02,711 DEBUG org.springframework.orm.hibernate.SessionFactoryUt ils - Opening Hibernate session
    2005-04-14 10:13:02,711 DEBUG net.sf.hibernate.impl.SessionImpl - opened session
    2005-04-14 10:13:02,711 DEBUG org.springframework.transaction.support.Transactio nSynchronizationManager - Bound value [org.springframework.orm.hibernate.SessionHolder@9d b94d] for key [net.sf.hibernate.impl.SessionFactoryImpl@29043] to thread [ExecuteThread: '14' for queue: 'weblogic.kernel.Default']
    2005-04-14 10:13:03,758 DEBUG org.springframework.beans.factory.support.DefaultL istableBeanFactory - Returning cached instance of singleton bean 'awardDetailServiceImpl'
    2005-04-14 10:13:06,477 DEBUG org.springframework.orm.hibernate.SessionFactoryUt ils - Opening Hibernate session
    2005-04-14 10:13:06,477 DEBUG net.sf.hibernate.impl.SessionImpl - opened session
    2005-04-14 10:13:06,477 DEBUG net.sf.hibernate.impl.SessionImpl - find:

    I want the hibernate template to use the session created by the filter. I also tried forcing it by setting allowCreate to false in the template, but it in turn throws an exception.

    Any help regarding this will be appreciated.

    Sudarshan.

  2. #2
    Join Date
    Apr 2005
    Posts
    6

    Default

    I am seeing that there are 2 application contexts created. Is there any way the I can make the openSessionInViewFilter use the one created by struts?

Similar Threads

  1. Replies: 1
    Last Post: Jul 5th, 2005, 03:48 AM
  2. pagination and continuation problem in SWF
    By yfmoan in forum Web Flow
    Replies: 6
    Last Post: Jun 29th, 2005, 03:42 AM
  3. Replies: 0
    Last Post: Feb 16th, 2005, 01:45 PM
  4. Oracle Jdbc invalid url problem
    By jfuchs in forum Data
    Replies: 5
    Last Post: Nov 1st, 2004, 11:33 AM
  5. Lazy Load Problem when Doing UnitTest
    By yoshi in forum Data
    Replies: 7
    Last Post: Sep 29th, 2004, 10:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •