From 42261a61dfba0204487a0261084aa0d7634ab5ae Mon Sep 17 00:00:00 2001 From: Emmanuel Bernard Date: Wed, 10 Nov 2010 12:23:38 +0100 Subject: [PATCH] HHH-5724 display the constraint failures on Bean Validation exception --- .../cfg/beanvalidation/BeanValidationEventListener.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationEventListener.java b/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationEventListener.java index e01ed63105..8b20eb9931 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationEventListener.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationEventListener.java @@ -146,12 +146,18 @@ public class BeanValidationEventListener implements classNames.add( violation.getLeafBean().getClass().getName() ); } StringBuilder builder = new StringBuilder(); - builder.append( "validation failed for classes " ); + builder.append( "Validation failed for classes " ); builder.append( classNames ); builder.append( " during " ); builder.append( operation.getName() ); builder.append( " time for groups " ); builder.append( toString( groups ) ); + builder.append( "\nList of constraint violations:[\n" ); + for (ConstraintViolation violation : constraintViolations) { + builder.append( "\t" ).append( violation.toString() ).append("\n"); + } + builder.append( "]" ); + throw new ConstraintViolationException( builder.toString(), propagatedViolations );