Skip to Content
0
Former Member
Jun 03, 2008 at 07:44 AM

Re: Something about Container-Managed Transaction

22 Views

Although I had already read the information about Container-Managed transaction, I still have some confuse on the Transaction Type : MANDATORY and REQUIRED

My situation is :

I am using the NW CE7.1 to implement the CAF

in the application service, I have implement a create operation as follow:

-


@javax.ejb.TransactionAttribute (javax.ejb.TransactionAttributeType.XXXXXXXX)

public <CustomerCreationRequest> create{

CustomerCreationRequestServiceLocal cs = this.getCustomerCreationRequestService();

//create customer

CustomerCreationRequest ccq = cs.create();

if(true){

throw new CAFCreateException();

}

}

public abstract class CustomerCreationRequestBean implements

CustomerCreationRequestServiceLocal {

@TransactionAttribute (TransactionAttributeType.REQUIRED)

public CustomerCreationRequest create

{

try{

// do create

}catch(DataAccessException _e) {

sessionContext.setRollbackOnly();

}

}

}

-


In the above method, an exception is thrown so that I can observe the behaviour of different transcation type

if the type is set to REQUIRED,

the transcation will not rollback, thus customer created

but if the type is set to MANDATORY

the transcation will rollback and no customer is created

as a result, these outcomes confuse me,

since I will guess that both transcation will be rollback.

So could anyone give me some explanation on the above situation. As I expcected no matter it is REQUIRED or MANDATORY, it should be execute in the same transcation context. But the result shows me they are in different transcation

really thanks in advance

DAVID