• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

hibernate with Container Managed Transactions (CMT)

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
anybody ??
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 77
Eclipse IDE Tomcat Server Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Tomcat Server Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply.

I heard that its possible with Spring. Is it correct?
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic