I just discovered a subtle bug in my application after upgrading to Hibernate Validator 6 and replacing my deprecated annotations from org.hibernate.validator.constraints with their counterparts in javax.validation.constraints.
The deprecated annotations packaged with HV were annotated with @NotNull. E.g.
Code:
@NotNull
@Size(min = 1)
@Deprecated
public @interface NotEmpty {}
Code:
@NotNull
@Repeatable(List.class)
@Deprecated
public @interface NotBlank {}
The new annotations do not include the @NotNull annotation. Is there a reason for this?
I'm currently scanning my entities for fields with @NotNull (or implied @NotNull) to mark those fields as required in my UI. This does not work anymore after the upgrade. Now I have to either scan for @NotNull, @NotEmpty, and @NotBlank or create my own composite annotations to maintain the current behavior. What is the recommended approach for this?
Thanks,
Thomas