Saturday, October 30, 2010

What is the best way to handle a ConstraintViolationException with EJB3 and entitymanager in an SLSB

Programmer Question

here is my code snippet:



@Stateless
public class mySLSB {

@PersistenceContext(unitName = "db")
private EntityManager myEntityManager;

public void crud(MyEntity myEntity) throws MyException {
myEntityManager.merge(myEntity);
}
}


However this merge can cause a ConstraintViolationException, which does not throw MyException (which is caught in the calling servlet).



What is the best way to catch hibernate exceptions ?



Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails