2 Replies Latest reply on Dec 20, 2005 10:18 AM by jonefun

    How to catch exceptions thrown by EntityManager

    phon

      hello,

      i wanna catch ConstraintViolationExceptions when persisting an entity, i noticed i had no result at first so i tried this :

      try {
       if (e.getId() == 0 ) {em.persist(e);}
       else { em.merge(e);}
       } catch (Exception exception) {
       logger.info("Caught exception from EntityManager.");
      }
      


      which gives no result. it seems the exception isn't thrown by the EntityManager operations? i do see the exception in the JBoss log as usual though

      anybody got an idea ?