0 Replies Latest reply on May 22, 2007 4:04 PM by Dustin Norlander

    Transaction confusion

    Dustin Norlander Apprentice

      Hello,

      My end goal is to have multiple db transactions within a single action method
      (similar to: http://www.jboss.com/index.html?module=bb&op=viewtopic&t=107449)

      I am using pojo with seam annotations, and I cant seem to get anything to work, and am getting very confused.

      for instance, I want to create have a method that tests rollback:

      @Rollback
      public void testRollback() {
       EmailAddr email = new EmailAddr();
       email.setEmail("test@test.com");
       this.entityManager.persist(email);
      }
      


      This is always commited?!? Shouldn't it rollback?

      Ultimately I would like to do something like:

      private void insertEmail(EmailAddr addr) {
      //start transaction
      this.entityManager.persist(email);
      //end transaction
      }
      
      public void insertEmails() {
      for (EmailAddr addr : emails) {
      insertEmail(addr);
      }
      }
      


      I've read everything in the forum, and in the hibernate book, but I still can't figure out how to do this. Any help?

      thanks,
      Dustin