Is any reason to put @NotNull annotation on @Id field in Java entity class
bean-validation, java, jpa
Solution
`@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.
Problem
I found code in entity class: ``` @Id @NotNull @Column(name = "ID") private Long id; ``` Is @NotNull annotation have value when @Id already set?