1 Reply Latest reply on May 24, 2005 8:46 AM by pbaker01

    TransactionManagementType Annotation

    pbaker01

      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");
       }
      }