aspose file tools*
The moose likes Object Relational Mapping and the fly likes hibernate with Container Managed Transactions (CMT) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "hibernate with Container Managed Transactions (CMT)" Watch "hibernate with Container Managed Transactions (CMT)" New topic
Author

hibernate with Container Managed Transactions (CMT)

abd hassan
Ranch Hand

Joined: Jul 15, 2003
Posts: 38
Hi,
I'm new to hibernate and trying to learn this technology. I'm trying to see how I can use hibernate in my domain layer with existing session beans facades in my service layer. How would transaction management work in this case. I'm currently running on websphere 5.1. I still want to use CMTs and let the container handle transactions set on my session beans instead of using explicit hibernate transactions. Is that feasible ? Is there any particular configuration setting required in hibernate to achieve that? Also, I usually hear about projects in which hibernate is used with Spring. How about the architecture where you have ejb session facades with hibernate. Is that a common approach ? Thanks for your help.
abd hassan
Ranch Hand

Joined: Jul 15, 2003
Posts: 38
anybody ??
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

Your approach is fine. Actually when you have a Hibernate Session and call beginTransaction on your Hibernate Sesison, and you currently have a CMT Transaction from your EJB, Hibernate will use and join that Transaction, rather than it "creating" its own. So if you rollback your CMT Transaction, all the stuff you used Hibernate for with data will also be rolled back.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
abd hassan
Ranch Hand

Joined: Jul 15, 2003
Posts: 38
Thanks so much. But there is another question. Why would you even bother to use hibernate explicit transaction management if you can handle it declaratively using CMT on a session facade. Also, I found this:

http://opensource.atlassian.com/projects/hibernate/browse/HHH-198

This seems to suggest that if you're using Websphere (which I am), then you'll have problem looking up the Container Transaction Manager. Maybe this is old information and the problem is fixed. I'm not sure. Please let me know if I'm missing something.

Thanks.
Dhawal Shah
Greenhorn

Joined: May 09, 2006
Posts: 2
Abd,

Check this IBM Technical article. I have successflly configured Hibernate to work with Websphere Transaction Management.

http://www-128.ibm.com/developerworks/websphere/techjournal/0409_patil/0409_patil.html

Good luck.

Dhawal
chets patel
Ranch Hand

Joined: Apr 27, 2010
Posts: 77

Hi Dhawal
Can you please tell me is it possible to use CMT in hibernate without EJB
I dont know EJB at all but I want to use CMT in hibernate.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

No. CMT is an intrinsic part of the EJB technology. If you want to use it, you need to be using EJB.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
chets patel
Ranch Hand

Joined: Apr 27, 2010
Posts: 77

Thanks for your reply.

I heard that its possible with Spring. Is it correct?
Sanjiv Tripathi
Greenhorn

Joined: Jan 12, 2012
Posts: 1
CMT is a form of declarative transaction management , it is possible with Spring's declarative transaction management using Spring AOP.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: hibernate with Container Managed Transactions (CMT)