1 Reply Latest reply on Jun 6, 2012 10:12 AM by jaikiran

    Is it possible avoid rollback from a particular exception ?

    warxsg

      Hi all,

       

      I have the following situation in a method of a Stateless EJB ( 3.0)

       

      public void writeInDB(String userName,String password) throws UserNotFoundException {

       

          //  call a Local EJB method

          User user = userDAO.updateUser(userName);

           if ( user == null ) {

                 logDAO.write("User not found");

                 throw new UserNotFoundException("user not found");

          }

      }

       

      The exception UserNotFoundException has the annotation @ApplicationException(rollback=true) inside

       

      Well,  from the cose above in case user==null I write a message "User not found" in the table and then I Throw an exception so the client, which calls the method "writeInDB" can understand better what's going on.

      The problem is that throwing the exception UserNotFoundException the message "User not found" is not written in database because it is made a rollback.

      So, is there any way to avoid this without using @ApplicationException(rollback=false) in the class UserNotFoundException ?

      I need to write some message in a table in case something goes wrong.

      Cheers.

       

                                 zoster