Win a copy of Svelte and Sapper in Action this week in the JavaScript 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Transaction Issues with session EJB.

Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have implemented Stateless Session EJBs with DAO (Simple JAVA classes) objects, wherein one of my stateless EJB method calls methods of multiple DAO (say CustomerDAO and OrderDAO).
First we are saving info in CustomerDAo and then into OrderDAO. While saving info in OrderDAO, if there are any exceptions then i want my transaction to be rolledback completely (i.e. entry in CustomerDAO should not be committed). I have tried to implement this by marking my sessioncontext as setRollbackOnly.
Right now if there is some problem in OrderDAO then my transaction is committed automatically (if autocommit is set to true). If i set it to false then it is not committed even if there is no error.
My transaction is specified as Container Managed - Required for all methods. Each of my DAOs are having their own connection object, set to AutoCommit "false". Also after putting connection to AutoCommit "FALSE", ORderDAO locks the corresponding Table.
Pls. inform any solution or work around for the same.
If i use Entity EJBs with Local Interface will it be of similar performance as my DAOs.
Eagerly waiting for any response.
Thanks & regards,
Tarun Dewan.
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We don't have many rules at Javaranch, but our naming policy is one of them. Please read this policy and change your display name to comply with it if you wish to continue posting. Thanks.
You can change your display name here.
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds as if you don't have your datasource configured properly. Basically, there are three "types" or configurations of datasources and these are configurable by the container, usually in some XML file or another.
The three types are:
1. Normal, non-transactional aware datasources.
2. Transactional aware datasources.
3. 2-Phase commit datasources
You'll have to look at the instructions of your container to see how to change your datasource to be transaction aware, which is item #2, unless you need transactions across different databases, then you'll need 2-Phase commit.
Further, when you get it right, you won't have to call setAutoCommit, you'll just let the container take care of it.
Barry's not gonna like this. Barry's not gonna like this one bit. What is Barry's deal with tiny ads?
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic