-->
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: Design pattern hibernate session in a ThreadPoolExecutor
PostPosted: Tue Jun 18, 2013 8:45 am 
Newbie

Joined: Tue Jun 18, 2013 8:25 am
Posts: 1
I have a ScheduledThreadPoolExecutor which runs a bunch of classes at fixed interval. In each of these bunch of runnable classes, a series of database operations & transactions is performed using hibernate, and these are handled manually. The problem is that there are many database operations and as a result there are many beginTransaction and commit in the code.

For example:
HibernateUtil.getSessionFactory().getCurrentSession().beginTransaction();
...//find , get, save...operations
HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().commit();

Is there a way to tie a hibernate session to the runnable class using good design principles?

The concept is to avoid making "..beginTransaction..or commit.." for every database transaction and let the thread pool in ScheduledThreadPoolExecutor handle the transactions at a higher level.


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.