- 
        1. Re: EntityManager and exceptionstzablock May 28, 2006 6:07 PM (in response to tzablock)Ok maybe I'll specify the question in a different way: 
 How can I use a non-injected entity manager?
- 
        2. Re: EntityManager and exceptionsana_oleski Jun 2, 2006 10:16 AM (in response to tzablock)Hi, 
 you could try the flush() method in the entityManager. It sends the sql to the database right away, that should generate your exception.
 Note that this has no influence on commit, you can still use container-managed transactions.
 Ana
- 
        3. Re: EntityManager and exceptionselponderador Jun 5, 2006 6:24 PM (in response to tzablock)Whether your EntityManager is injected or not has nothing to do with your ability to catch an exception. 
 You can do this:try { em.persist(user); } catch (Throwable t) { if (t instanceof TheExceptionIAmWantToHandleLaterException) { ... } else { ... } }
- 
        4. Re: EntityManager and exceptionselponderador Jun 5, 2006 6:26 PM (in response to tzablock)Sorry forgot to include this (this would go in the implementation class): public void createUser (...) { try { this.createUserImpl(...); } catch { ... } } private void createUserImpl (...) { em.persist(user); }
- 
        5. Re: EntityManager and exceptionsjc7442 Jun 6, 2006 3:17 AM (in response to tzablock)In your createUser method you could catch the exception and throw a new Exception (with the annotation ApplicationException with the rollback set to false). 
 Exception handling is describe in chapter 14 of the EJB core specification
 
     
     
    