I want Ebean in Play Framework to make some columns in my tables 'not null'. Is it possible to the @NotNull annotation? If yes, which package should I import? I tried with import com.avaje.ebean.validation.NotNull; but I got an error saying this package can't be found.
Note that the accepted answer is no longer correct.
com.avaje.ebean.validation.NotNull no longer exists and instead you can use javax.validation.constraints.NotNull
Secondly you do not need to specify @Column(nullable = false) if the @NotNull annotation is used. Ebean takes the existence of @NotNull as meaning that the DB column is not null and handles that appropriately.
It's indeed com.avaje.ebean.validation.NotNull;
check this topic for solution:
https://groups.google.com/forum/#!msg/play-framework/azlPQ14XJ2I/tdOKUkYVAxAJ
BTW:
You need to use @Column(nullable = false) annotation if you want you column to be not nullable (the restriction will be enforced by DB).
@NotNull is for validation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With