Hibernate Validator 4.0.0 Alpha3

Posted by    |      

Hibernate Validator version 4.0.0 Alpha3 is of now available. This implementation is based on JSR 303 Specification 1.0.CR1[1]. The distribution packages contain everything you need to get started.

As promised in the last post implicit grouping is now available. On top of this the metadata API is now in sync with the current spec and there is a JPA 2 aware TraversableResolver. @Valid supports now Iterables and the cascading algorithm follows the new graph navigation rules. In the previous releases an object instance would only be validated once per group. Now this instance can be validated once per group AND validation path. Lets look at the object graph below to illustrate the change:

Assuming a @NotNull constraint on Address.addressLine validating the shown Order instance against the default group will now result in three ConstraintViolations differing only in the property path. The paths are:

  • shippingAddress.addressline1
  • customer.addresses[0].addressline1
  • billingAddress.inhabitant.addresses[0].addressline1

Previously only one ConstraintViolation would have returned and it was not defined which property path it would contain. Last but not least the ConstraintValidator resolution algorithm got revamped and works now with generics. This allows support for constructs like:

Collection<? extends Number> element;

For further information about this release refer to the Jira change log and please provide us with some feedback.


Back to top