-->
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.  [ 3 posts ] 
Author Message
 Post subject: LocalSessionFactoryBean & OpenSessionInViewInterceptor
PostPosted: Mon Nov 14, 2005 5:44 pm 
Newbie

Joined: Fri Aug 05, 2005 12:03 pm
Posts: 5
Apparently to get LocalSessionFactoryBean to actually be able to use a session during a web page, one must use the OpenSessionInViewInterceptor.
I've managed to modify the example code from the SpringBlog application that comes with the book, Pro Spring to do just that. Seems to work ok.

Now the tricky part. I'd like to have junit tests that test the configuration of hibernate and spring in a config as much like the production environment as possible.

So, I've created a fragment spring/hibernate xml config that includes the data source, transaction manager, sessionfactorybean, hibernate config and a dao object.
However, not being able to use OpenSessionInViewInterceptor here has me confused as to what I might do to open and close the session for the duration of the junit test.

My PackageDoa object extends HibernateDaoSupport, which in the config gets LocalSessionFactoryBean, which in turn gets a datasource.

TransactionProxyFactoryBean is used to proxy for PackageDao. TransactionProxyFactoryBean gets a SessionFactoryBean.

So I have this in my unit test:

PackageDAO dao = (PackageDAO) factory
.getBean("packageDAO");

However, I get the error, "could not initialize proxy - the owning Session was closed" just like before I added the OpenSessionInViewInterceptor to the servlet config, however, now, no servlet...

What does one do?

thanks


-j


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 14, 2005 6:08 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Go to the Spring forum.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 14, 2005 7:51 pm 
Beginner
Beginner

Joined: Fri Oct 28, 2005 10:46 am
Posts: 37
christian wrote:
Go to the Spring forum.


Or a JUnit forum or any general web development forum where things like this would be common problems. This has nothing to do with Hibernate beyond the fact that you're using it as a library.


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

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.