Search code examples
javahibernatespring-mvchibernate-validator

Hibernate validator how to validate the object including its related objects?


I have a Event class, with many to one Person objects associated with it, (which in turn has its own validator annoations on it. When I validate my Event class though, it's not calling the validation on the related object?

Set<ConstraintViolation<Event>> cv = getValidator().validate(i);

Solution

  • Annotate the Person field in Event with @Valid to have the validation also validate the Person instance.