Thursday 4 February 2016

Validation of Beans

Just a small utility function that prints out readable messages on what is wrong with a certain bean (like for example a JPA Entity).

Got a little miffed with the fact that my javax.validation.ConstraintViolationException that is thrown, never shows the exact problem. I always have to drill down into the Exception to find the message in order to fix the problem.

I hope it helps someone.

See for more information about bean validation JSR 303.

References

The Java EE 6 Tutorial - Using Bean Validation
http://docs.oracle.com/javaee/6/tutorial/doc/gircz.html
The Java EE 6 Tutorial - Validating Persistent Fields and Properties
https://docs.oracle.com/cd/E19798-01/821-1841/gkahq/index.html

No comments:

Post a Comment