Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

CMT: Container Management Transaction

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i try to practice EJB3.0 transactions, i use the CMT mode (declarative) so :

I create my EJB with entites and I use the entityManager to manage data
I use the annotations
I have amready created two methods in the implementation classes :

there are my methods

public void ajouterClient(Client Client) {

public void createReservations(Reservations reservations) throws Exception{
System.out.println("entities saved");

public void reservation(Client client, Reservations reservation) throws Exception{



it seems to be correct, there is no compilation error either execution error, but I when call the reservation method I try to force the roll back in the container wiyh the method creatReservation, but ther is no roll bacj the insertion of the client is finished correctly.
NB : the transaction should be managed implicitly by the EJBcontainer (it use the method SetRollBackonlly() )

is there an body that have an idea how the container managed the transactions and was is wrong in my code !!

thank you !

Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Notice that if you want the EJB container to be aware of transactions annotations (actually, any method annotation), you must invoke the methods as follows:

1- You can use a reference to itself using Dependency Injection:

2- Or you can use the SessionContext interface:

If you use the "this" keyword, the container will ignore transaction annotations.

Hope this helps,

There are 10 kinds of people in this world. Those that understand binary get this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic