I am trying to persist the entity with constraint validation,
when invoke persist - there is constraint that thrown and the caller get EjbTransactionRolledbackException
...
so I try to call the validation explicit and throw ConstraintViolationException
/RuntimeException
and still the caller get EjbTransactionRolledbackException
...
when I throw MyException
extends Exception
- the caller get MyException
Even when I call explicit sc.setRollBackOnly
it's still happened :(
This shouldn't be the behavior.
what's going on?
Configuration:
Netbeans 6.9.1 Glassfish 3.0.1 JPA 2.0 (EclipseLink) EJB 3.1
Thanks!!!
@Stateless
public class My {
@PersistenceContext
EntityManager em;
@Resource
Validator validator;
public Order checkout(Order order) {
Set<ConstraintViolation<Order>> set = validator.validate(order, Default.class);
if (!set.isEmpty()) {
sc.setRollbackOnly();
//throw new ConstraintViolationException(new HashSet<ConstraintViolation<?>>(set));
throw new RuntimeException();
}
this.em.persist(order);
}