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 LicenseBean
and LicenseBeanFacade
classes from the ValidationApplication
as discussed in the Validating persistent fields and properties recipe.
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;
If the field must contain a null, then the @Null annotation is used.
@Null private String name;
3.143.205.27