Has this problem been solved?
I have another question about the cache in this scenario,
say that a client invokes the sessionbean's two methods within one transaction, if the first method update an object A,  and then second method updates another object B, and then the client rollback, will the object A or B in cache be rollbacked too?
As I haven't read the source code, I am wondering how the cache mechanism handle these situations?
Thanks a lot,
John W
----- Original Message -----
Sent: Monday, December 31, 2001 6:42 AM
Subject: [castor-dev] Problem with transactions when using JBoss + Castor JDO

Hi,

 

I’m trying to use Castor JDO with JBoss but having some problems with transactions.

My client starts a transaction and tries to call session bean methods two times. Each of them  saves an object into the db:

userTran.begin();

bean=ServiceBroker.getBean();

try {

bean.createObject(obj1);

bean.createObject(obj2);

userTran.commit();

} catch (Exception e) {

userTran.rollback();

}

 

When stateful session bean is activated, its field _jdo is initialized:

public void setSessionContext(SessionContext sc) {

try {

InitialContext ic = new InitialContext();

_jdo = (DataObjects) ic.lookup("java:comp/env/jdo/castor");

} catch (Exception e) {

e.printStackTrace(System.out);

}

}

 

Then, when the createObject() from the client is called I do the following:

db = _jdo.getDatabase();

db.create(o);

db.close();

 

Then I try to commit the transaction in the client. The bean transaction attribute is Mandatory and it must join the client transaction.

The problem is that when the exception is thrown in the second call in the bean and therefore I try to rollback the transaction it doesn’t happen and the first object is save in the db however I need to save both or none.

 

Can anyone help me here?

Thanks a lot

 

Alex Ryltsov

Reply via email to