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:
#Why new entity is saved with null field value when annotation tells that the value cannot be null?
1 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @latent condor! Please use
/closeor theClose Postbutton 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.
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.