I'm using EclipseLink 2.5 with JPA 2.1 in standalone java application.
Some field are marked with @Basic(optional=false), but even with null value I didn't get any error before commit. The constraint is set on database so I got a JDBC exception.
Adding Hibernate Validator to project and setting validation mode to callback didn't help.
Only with @NotNull annotation on field I got exception: javax.validation.ConstraintViolationException: Bean Validation constraint(s) violated while executing Automatic Bean Validation on callback event:'prePersist'. Please refer to embedded ConstraintViolations for details.
which is not very specific and does not inform where the problem is.
I would like to know if there is any way to make this message look more robust: like field name not set or something like this and force eclipselink to check optional=false.
EDIT: I know the difference between JPA and Bean Validation. I am trying to perform validation with JPA only, using optional=false. As far as I know (@Basic(optional = false) vs @Column(nullable = false) in JPA) @Basic(optional=false) should be checked at runtime and @Column(nullable=false) should be used to make column nonnullable in the database.
I'm looking for a method to display violations with out catching ConstraintViolations everywhere.