aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate and EJB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate and EJB" Watch "Hibernate and EJB" New topic
Author

Hibernate and EJB

wu jong
Greenhorn

Joined: May 31, 2005
Posts: 13
we intend to develop a j2ee app using ejbs and the struts framework in the middle and jsp in the front. also expected is a mysql backend accessible via hibernate layer from the ejbs.

for the above scenario, how/where should the transaction management be done ? are there any additional guidelines ?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

If you have decided to use EJB, then the how and where is probably Container Managed Transactions from the EJB. I'm sure you will be aware of this too, but make sure you use a mydsql database engine which supports transactions because not all do.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
wu jong
Greenhorn

Joined: May 31, 2005
Posts: 13
Oh so should I switch off the transaction management in hibernate. How can I make a CMP Transaction effectively roolback on my DAO that uses Hibernate internally ?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Remember that Hibernate/JDBC transactions are different from JTA transactions. If you are calling your Hibernate code from inside a CMT EJB method, you won't use the Hibernate transaction API directly at all. Typically Hibernate recommend a "Session per business (JTA) transaction" approach. This basically means when you call your DAO code from a business method it opens a session, and does a bunch of persistance stuff (possibly accross many DAO's). At this point you are working against the session, not the database. When the last persistance operation of your CMT method finishes, the session is flushed and closed. If you wan't to roll back any of the Hibernate operations which happened in this CMT you do it just as you would for any CMT method; the presence of Hibernate doesn't make a difference.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate and EJB
 
Similar Threads
Hibernate
Hibernate with EJB
Hibernate with EJB3
jboss-ejb-Stateless?
How to configure weblogic so that it will log all sql statements sent to database.