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:
No description
No description
6 Replies
JavaBot
JavaBot2y ago
This post has been reserved for your question.
Hey @Tomasm21! Please use /close or the Close 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.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Tomasm21
Tomasm21OP2y ago
Spring 3.0.5
dan1st
dan1st2y ago
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
Tomasm21
Tomasm21OP2y ago
That's right. Thanks.
JavaBot
JavaBot2y ago
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.
JavaBot
JavaBot2y ago
Post Closed
This post has been closed by <@312509109863710732>.
Want results from more Discord servers?
Add your server