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: Hibernate DAO best practices
PostPosted: Wed Nov 24, 2010 11:23 am 
Newbie

Joined: Wed Sep 27, 2006 2:26 pm
Posts: 6
I am working on creating a library that contains entities and DAO for a database. Most examples/tutorials I have seen do not have any notion of transactions in them. Is this because the calling application should wrap the DAO method calls in the beingTransaction(), commit() / rollback() code, or is there an easier way to do things?

I have looked in to using only hibernate libraries and am not looking into using Spring to help manage the database operations.

Thanks in advance,
Mark


Top
 Profile  
 
 Post subject: Re: Hibernate DAO best practices
PostPosted: Thu Nov 25, 2010 5:41 am 
Senior
Senior

Joined: Tue Oct 28, 2008 10:39 am
Posts: 196
elihusmails wrote:
I am working on creating a library that contains entities and DAO for a database. Most examples/tutorials I have seen do not have any notion of transactions in them. Is this because the calling application should wrap the DAO method calls in the beingTransaction(), commit() / rollback() code, or is there an easier way to do things?

I have looked in to using only hibernate libraries and am not looking into using Spring to help manage the database operations.

Thanks in advance,
Mark


It depends... If you DAO covers a complete business case and not only a part of it, you could do the transaction management inside. But I would recommend NOT to do so. In a few months you have to extend your use case and use a second DAO then you have to span the transaction over both DAOs.
If you use Hibernate inside a JBoss (or any other JEE-Server) you can leave transaction management to that server.


Top
 Profile  
 
 Post subject: Re: Hibernate DAO best practices
PostPosted: Thu Nov 25, 2010 9:17 am 
Newbie

Joined: Wed Sep 27, 2006 2:26 pm
Posts: 6
Thanks. I am doing this inside ActiveMQ which does not have transaction management, so I am managing things by myself.


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.