This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Tx management for non-bean classes  RSS feed

 
Reena Kher
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have a question abt tx management. I have a session fa�ade layer that talk to an intermediate layer. This layer talks to entity beans. A method in session fa�ade calls a method say addCustomer() in intermediate layer. This is a hypothetical example. AddCustomer() method talks to 2 entity beans. A customer and a address bean. It first calls create on customer and then create() on address bean. Now if there is any exception while create() call of address, I want to rollback create on customer. I can always do that by calling remove on customer bean. However, I want to know is there any std way to handle such transactions. I can not use tx attribute �required� for addCustomer() method as it not a method of session fa�ade , rather it belongs an intermediate controller class. So how can I use container managed tx (CMT) in such a case? Is there any std pattern to do this?

Any help would be appreciated.
 
Judd Smith
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Reena,
What you are trying to do is perfectly reasonable and fits in well with the EJB CMT concept.
Let's say your facade session bean has an entry method named processRequest(). This is the entry method that eventually calls addCustomer() in your example.
If somewhere in the processing of processRequest(), including all of its calls to all of its helper methods, it calls the setRollbackOnly() method of the SessionContext object, all database accesses done during that method call (processRequest())will be undone. I think that's what you want.
It certainly works that way with the WebLogic server.
Good luck,
Judd Smith
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!