#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)

latent condor
#

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:

vagrant lotusBOT
#

This post has been reserved for your question.

Hey @latent condor! 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.

latent condor
#

Spring 3.0.5

polar falcon
#

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

latent condor
#

That's right. Thanks.

vagrant lotusBOT
# latent condor 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.