Confusion: @NotNull vs. @Column(nullable = false) with JPA and Hibernate

  1. When they appear on a field/getter of an @Entity, what is the difference between them? (I persist the Entity through Hibernate).

  2. What framework and/or specification each one of them belongs to?

  3. @NotNull is located within javax.validation.constraints. In the javax.validation.constraints.NotNull javadoc it says

    The annotated element must not be null

    but it does not speak of the element’s representation in the database, so why would I add the constraint nullable=false to the column?

4 Answers
4

Leave a Comment