Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hibernate with Container Managed Transactions (CMT)

 
abd hassan
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anybody ??
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
abd hassan
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 77
Eclipse IDE Redhat Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. CMT is an intrinsic part of the EJB technology. If you want to use it, you need to be using EJB.
 
chets patel
Ranch Hand
Posts: 77
Eclipse IDE Redhat Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply.

I heard that its possible with Spring. Is it correct?
 
Sanjiv Tripathi
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
CMT is a form of declarative transaction management , it is possible with Spring's declarative transaction management using Spring AOP.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic