-->
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: DAO v.s. abstracting long sessions
PostPosted: Fri Feb 10, 2006 10:43 am 
Newbie

Joined: Mon Jan 30, 2006 5:14 pm
Posts: 8
Location: Amsterdam, Netherlands
Hi,

DAOs abstract client code from making (Hibernate) specific data access calls.

For long sessions, however, it looks like there is no abstraction from storing the Hibernate session in e.g. the Web session context.
Assuming a requirement for supoprting different persistence frameworks, wouldn't it make sense to add such an abstraction level too ?


I am thinking of:

- Hibernate Util keeps the thread local variable.

- Add a thin, Hibernate-independent layer on top of Hibernate Util. Let's call this layer MyPersistenceManager.

- MyPersistenceManager has, amongst others, methods reconnect(), and disconnect(). These are Hibernate independent.

- Upon thread termination, MyPersistenceManager.disconnect() will save the thread-local variable from HibernateUtil into a MyPersistenceManager instance variable. This variable is not visible to client code. It will be saved when MyPersistenceManager is saved, e.g. into the Web session context by a servlet filter.

- Upon starting a new thread, MyPersistenceManager.connect() is called by e.g. a servlet filter. MyPersistenceManager.connect() will hand-over the MyPersistenceManager instance variable back to HibernateUtil, via HibernateUtil.reconnect(session). The MyPersistenceManager instance variable will be nullified.

Note: we are currently targeting at Hibernate 3.0. When adopting Hibernate 3.1 later, it looks like the TransactionInterceptor can be useful; however this only supports session per request ?


Regards,

- Fernand.


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.