This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
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 ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Transaction Rollback Fails

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am calling the create() of 2 CMP beans one after the other in a session bean method. In the 2nd CMP create() method i am throwing an exception. This exception is caught in the session bean method where context.setRollBack() is called. Both the CMP beans have transaction set to SUPPORT and the session bean is set to REQUIRED.
I assumed that the 1st create() method would rollback too but i find in the database that the record exists. The 2nd create() method has failed.
This is what i tried:
a. Transaction attributes of all 3 beans.
b. Both user managed and container managed transaction.
I must be missing something.
Thx in advance.
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
You could possibly get your piece of code posted here, that would give a clear picture of what you are trying to do.
One reason could well be the usage of the type of datasource you use. TX DataSource to be used for transactions. Give it a shot and do give your feedback.
Regards.
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
try to starts your own transaction by using "UserTransaction", put the code between the ut.begin() and end with ut.commit() or rollback(), this will solve your problem.
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make the cmp transaction attribute as "Required" as both Required and Supports is similar in nature with one exception and that is in case "required" a new transaction is started if one is not running already but support will sometimes not run within a transaction .
 
Subhash Nambiar
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make the cmp transaction attribute as "Required" as both Required and Supports is similar in nature with one exception and that is in case "required" a new transaction is started if one is not running already but support will sometimes not run within a transaction .

Subhash
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What application server (and version) are you using and which version of the EJB spec are you writing to? It really does make a difference...
Kyle
 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Earlier implementations of EJB were "loose" on the inclusion of home methods (like create) in a transaction (because the spec was vague). I forget when it changed (1.1 or 2.0), but with the current spec you can specify Home and/or Remote interface in the method element of the deployment descriptor where you are describing the transaction attributes.
Make sure the Home create method is included in your transaction settings.
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic