-->
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: Ideal service layer/DAO layer design
PostPosted: Fri Dec 30, 2011 11:38 am 
Newbie

Joined: Wed Aug 04, 2010 8:35 am
Posts: 5
Location: Washington DC
We are in the process of developing a new J2EE web application that is going to be deployed on Websphere 7.
We are going to use Java 6 and hibernate 3.6 for persistence. We will be using JPA annotations for POJOS.My question is what is the ideal architecture for Service Layer/DAO layer when using hibernate.When we used hibernate 5years ago, the design was using spring's hibernate template and spring's hibernate transaction manager. I know there has been some advancements in hibernate and spring in the last five years, which I couldn't keep track. So I'm looking to find the ideal architecture for Service layer/DAO layer. Is Spring a still must have with hibernate. I read somewhere that the latest hiberante has built in feature similar to the spring hibernate template. BTW we will be using Flex for the front end and Granite DS to talk to the Java service layer backend. So we won't be using Spring MVC. Any useful links/documents with sample code will be greatly appreciated.


Top
 Profile  
 
 Post subject: Re: Ideal service layer/DAO layer design
PostPosted: Fri Dec 30, 2011 12:11 pm 
Newbie

Joined: Wed Nov 10, 2010 4:24 pm
Posts: 6
You don't need spring to use hibernate. You can use Hibernate quite easily on it's own and integrate it into most SOAs:

http://docs.jboss.org/hibernate/core/4. ... ew-minimal

The manual is actually quite informative and thorough:

http://docs.jboss.org/hibernate/core/4. ... n-US/html/

I do recommend researching annotations over XML for setting up ORMs.


Top
 Profile  
 
 Post subject: Re: Ideal service layer/DAO layer design
PostPosted: Fri Dec 30, 2011 2:01 pm 
Newbie

Joined: Wed Aug 04, 2010 8:35 am
Posts: 5
Location: Washington DC
Thanks. What I wanted to avoid was the repetition of the following code in every DAO method to open & close the session and do the transaction management.


Session sess = factory.openSession();
Transaction tx = null;
try {
tx = sess.beginTransaction();

// do some work
...

tx.commit();
}
catch (RuntimeException e) {
if (tx != null) tx.rollback();
throw e; // or display error message
}
finally {
sess.close();
}
jhuntley wrote:
You don't need spring to use hibernate. You can use Hibernate quite easily on it's own and integrate it into most SOAs:

http://docs.jboss.org/hibernate/core/4. ... ew-minimal

The manual is actually quite informative and thorough:

http://docs.jboss.org/hibernate/core/4. ... n-US/html/

I do recommend researching annotations over XML for setting up ORMs.


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.