I am using JBoss Seam with 6, and I have the essence, I'm trying to save User. I expanded org.jboss.seam.framework.EntityHometo provide a class UserHomeand redefined the method persist(). I completely annotated the entity class with javax.validation annotations. When I provide valid values for all fields in an entity class, the object is saved without problems. When I violate one of the validation restrictions, persistence fails as expected.
The problem I am facing is related to violation of restrictions during asynchronous saving: hibernate does not tell me what restriction was violated!
javax.validation.ConstraintViolationException: validation failed for classes [com.example.model.User] duringpersist time for groups [javax.validation.groups.Default, ]
at org.hibernate.cfg.beanvalidation.BeanValidationEventListener.validate(BeanValidationEventListener.java:132)
at org.hibernate.cfg.beanvalidation.BeanValidationEventListener.onPreInsert(BeanValidationEventListener.java:71)
If I force synchronously save by adding EntityManager.flush()in UserHome.persist(), I can catch ConstraintViolationExceptionand output logical operators containing violated restrictions.
My question is: is it possible to register a listener with hibernate / jboss for restriction violations? I think it’s a little lame, that hibernate does not print violations, but I hope I can insert some code that will catch and log them for more information. Otherwise, I do not know which restriction has been violated.
Thank!
source
share