Why new entity is saved with null field value when annotation tells that the value cannot be null?
I am trying to do JUnit test and save new Book and Category. However one of the fields cannot be null. O r I think it should be like this. To achieve this I use annotation
@NonNull
. But actually the entity is still saved with NULL
value. Can you tell me why? And can you tell me what to do so Null value fields could not be saved and instead Spring would show an exception?
View:6 Replies
⌛
This post has been reserved for your question.
Hey @Tomasm21! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
Spring 3.0.5
If you are using Lombok,
NoArgsConstructor
ignores NonNull
and if you want your element in the DB to not be nullable, use @Column
with nullable=false
That's right. Thanks.
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
Post Closed
This post has been closed by <@312509109863710732>.