Validating null fields
Object references are used extensively in Java. Assigning a null value is not an uncommon practice though they need to be assigned a value before a method can be executed against it. Fields of a database may or may not be allowed to contain a null value. The @Null and @NotNull annotations can be used to indicate whether a reference field can be assigned a null value or not.
We will use the
LicenseBeanFacade classes from the
ValidationApplication as discussed in the Validating persistent fields and properties recipe.
How to do it...
If we want to prevent a column of a database from being assigned a value of null, then we can enforce this with the @NotNull annotation.
@NotNull private String name; ...