I found code in entity class:
@Id
@NotNull
@Column(name = "ID")
private Long id;
Is @NotNull annotation have value when @Id already set?
@NotNull
is for validation purposes, like @Size
. It defines rules for a validation engine to check whether user input is ok. Doing validation around these annotation doesn't necessarily indicate that the object is also a JPA object but the two are often used together.
If you're using javax.validation instead of relying on failure at the DB level (constraint violations) to indicate null values, then you should use both annotations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With