-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Problem regarding OpenSessionInViewFilter
PostPosted: Thu Apr 14, 2005 11:15 am 
Newbie

Joined: Fri Mar 18, 2005 4:42 pm
Posts: 5
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.OpenSessionInViewFilter
</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.OpenSessionInViewFilter - Opening single Hibernate session in OpenSessionInViewFilter
2005-04-14 10:13:02,711 DEBUG org.springframework.orm.hibernate.SessionFactoryUtils - 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.TransactionSynchronizationManager - Bound value [org.springframework.orm.hibernate.SessionHolder@9db94d] 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.DefaultListableBeanFactory - Returning cached instance of singleton bean 'awardDetailServiceImpl'
2005-04-14 10:13:06,477 DEBUG org.springframework.orm.hibernate.SessionFactoryUtils - 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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.