I have created a model with the following field
@NotNull
@Column(name = "postal_code")
private String postalCode;
When I try to post a JSON without the postal code, It should not be saved to the database. That's the reason I have used @NotNull annotation, But to my surprise, It's saving to the database even though the postal code is empty.
So then, I used
@Column(name="postal_code" , nullable=false) //instead of @NotNull
By changing the code as shown in the above, It's not saving to the database with an empty postal code.
My question is why it's not working with @NotNull and what is the diff b/w @NotNull and nullable