-->
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: Why doesn't StatelessSessionImpl implement Session?
PostPosted: Tue Jul 10, 2007 1:16 pm 
Newbie

Joined: Sun Apr 23, 2006 1:23 am
Posts: 3
I'm converting an OracleForms application to a Java web application. Due to the structure of OracleForms, I'd like to use Hibernate's StatelessSessionImpl class instead of SessionImpl as the Hibernate Session implementation. We are also using the Spring Framework to configure Hibernate.

Since I'm using the Spring Framework's HibernateTemplate and OpenSessionInViewFilter, it is not easy to setup my DAO code to use Hibernate's StatelessSession. I thought I might be able to subclass SessionFactoryImpl to return instances of StatelessSessionImpl instead of SessionImpl when openSession() is invoked. However, this doesn't work since there is a separate interface named StatelessSession that StatelessSessionImpl implements as opposed to just implementing the Session interface and doing something to fake out the methods on the Session API that don't make sense in the context. So, I'm going to try to make an adapter class that implements the Session interface and uses an instance of StatelessSessionImpl for some operations and try to do something reasonable for the other methods defined by the Session API.

I was just wondering if there is a good reason why StatelessSessionImpl doesn't do this already before I put much effort into trying to make this work only to find out that there was a reason that this can't be done.

Nathan


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 10, 2007 1:47 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Do not use the Spring stuff, even the Spring developers no longer recommend it; we never did. (Search the Spring guys blog.)

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 10, 2007 2:36 pm 
Newbie

Joined: Sun Apr 23, 2006 1:23 am
Posts: 3
OK. I searched and see that we don't need to use HibernateTemplate
(Spring HibernateTemplates or Not).

In any case, I'd like to be able to call sessionFactory.getCurrentSession().update(myObject) where the object returned by getCurrentSession() is a StatelessSessionImpl that implements the Session interface. So, I believe I still need to make a class that implements Session ("StatelessSessionAdapter") and also subclass SessionFactoryImpl and override the getCurrentSession() method.

Any reason not to do this? Other than the fact using StatelessSession is questionable, but because of the nature of this legacy re-development, we think this makes sense in this case.

I am curious why the Hibernate developers didn't do this to start with considering that they did provide the StatelessSession. However, the DAO code has to change to use it. I think the choice of stateless or regular Session implementations should be configurable.

Nathan


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.