Hi,
Jboss: jboss-4.0.1sp1
I'm new to EJB3... I'm using Hibernate/Spring/JTA in my Stateless EJB. I want to manage the Txn.. Currently the commit does not occur until I exit the EJB and I want to catch/handle persistence exceptions before I exit. Here is how I define the EJB...
What am I doing wrong...
@Stateless(transactionManagement=TransactionManagementType.BEAN)
public class ActypeCrudBean implements ActypeCrud {
...
...
public void update(ActypeTO actypeTO) {
Actype actype = ActypeAssembler.getDO(actypeTO);
ActypeService service = (ActypeService) context.getBean("actypeService");
service.update(actype);
return;
}
public void update(final Actype actype) {
try{
TransactionTemplate transactionTemplate = new TransactionTemplate (this.getTransactionManager());
transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
public void doInTransactionWithoutResult(TransactionStatus status) {
actypeDao.update(actype);
}
});
} catch (OptimisticLockingFailureException e) {
throw new OptimisticLockingException();
} catch (StaleObjectStateException e) {
throw new OptimisticLockingException(e);
} catch (Exception e) {
System.out.println("testtstst");
}
}Never mind... just after I posted I saw that I had specified
PROPAGATION_REQUIRED instead of PROPAGATION_REQUIRES_NEW.... When PROPAGATION_REQUIRES_NEW is specified then I can handle my TXNs... ;)