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

trnsaction rollback is not happening with context.setrollbackOnly()  RSS feed

 
krishna chitturi
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i have an MDB, Entity bean and DAO.
i am calling entity bean from mdb.in deployment descriptor i specified NotSupported for mdb trnsaction type attibute. for entity it is Required.
if i get some exception from DAO i am catching that in Entity and there i am doing contect.setRollbackOnly().
but it is not rolling back the updates/inserts before the exception.
is my dd is wrong
please help me.
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try changing the setting in the MDB to REQUIRES rather than NOT_SUPPORTED. Since the outer transaction context is not established (you didn't tell the container to create one when you set the MDB setting to NOT_SUPPORTED) there is a wholly new one established for each call to the Entity bean. Of course things that happened before that aren't rolled back -- they're not in the same transaction!
Kyle
 
krishna chitturi
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks,
but the transaction will be there in the entity right, but the insertions/ updations happend in that entity are also not rolling back.
any way i will try with requires in MDB.
we are not doing setRollback only in MDB , then what is the point of maintaining transaction in MDB
please clarify???
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Krishna, What you are trying to do is the following
MDBMEthod Start
call ----->EntityMethodA
call ----->EntityMethodB
call ----->EntityMethodC
MDBMethod End
Right? The scope of the transaction is based on the thread and the object. Since you have the MDB set to "Not Supported" then each method call (A,B,C) is its own transaction. What you have to do to get A or B to rollback if C has a problem is to create a transaction that spans all three calls. The way to do that is to create the transaction when the MDBMethod begins, which is what setting the MDB to REQUIRED will do.
Kyle
 
krishna chitturi
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi thanks for your reply.
but that is not my problem.
my implementation is like this:
Entity method A calls - DAO1
- DAO2
- DAO3
i got the exception from DAO3 i have to rollback whatever DAO1 and DAO2 did.
in entity method i am doing rollback but it is not happening.
please help me.
 
Sam Wang
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also meet the same problem.
a entity bean:
1.modify some data through get&set method;
2.call a method at itself about some jdbc code;
3.modify other data through get&set method.
1 sucess;
2 some exception throws;
3 roll back;
But the data modified at step 1 has been modified!
[env]
wls6.0
oracle8.1 or sqlserver7.0
 
krishna chitturi
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
we got solution to the problem.
for us we are using norrmal datasource, when we shifted to TXDataSource rollback is happening.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!