Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Transaction through EJB3

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I created an application that has EJB3 and Hibernate3. Initially I was jus calling the method in Dao layer from EJB and there for every method get new hibernate session and do the transaction and so on...
Now i hav ben asked to do all the transaction from EJB layer itself. I have no clue how to begin with the same. i am using stateless session beans. and MySql database.
 
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
I recommend you go through this useful tutorial.
 
Jyoti Aggarwal
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am not able to undestarnd that is it necessary to use persistance.xml. Initially I was using hibernate.cfg.xml. If yes where am i going to map hbm.xml mapping and how to call the session
please its really urgent
 
Paul Sturrock
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
So you question is not about container managed transactions its about transaction scoped session management? In which case the Hibernate documentation will explain what to do.
 
Jyoti Aggarwal
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have already gone through that ....
Ok I have one DAO layer having sesssionFactory of hibernate. then there is this class doing all transaction




In my EJB folder
I have put


have no idead whether PersistenceContext private EntityManager em; is required or not

No how do i open transaction in ejb
 
Paul Sturrock
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 how do i open transaction in ejb


See my first reply. The mechanism is called container managed transactions and is one of the basics of EJBs. I would strongly recommend you go through the linked tutorial before doing much more with EJBs. It will make your life much easier if you have a good grasp of the basics
 
If we don't do the shopping, we won't have anything for dinner. And I've invited this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic