Quando utilizo o Hibernate Validator (3.1.0) com o Spring (2.5.6) não consigo capturar a InvalidStateException diretamente. O Spring lança uma JpaSystemException, que tem como causa uma RollBackException, que por sua vez tem como causa a InvalidStateException. O mesmo ocorre com PersistenceException e IllegalArgumentException em métodos que implementei, como no exemplo abaixo:
@PrePersist
@PreUpdate
protected void prePersist(StReservaVeiculo reserva)
{
if(reserva.getKmInicial() != null && reserva.getKmFinal() != null &&
reserva.getKmInicial() > reserva.getKmFinal())
{
throw new PersistenceException("KM inicial maior que KM final");
}
}
No DAO está da seguinte forma:
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public void persist(T t)
{
em.merge(t);
}
Isso é normal?
Obrigado,
Felipe