Reputation: 170
I'm wondering if there is an option in hibernate where I can configure a manytomany field to be required? Normally I would add nullable = false but it can't be added inside these annotations.
@ManyToMany(cascade = { CascadeType.ALL })
@JoinTable(name = "attribuutlabel",
joinColumns = { @JoinColumn(name = "valueid") }, inverseJoinColumns = { @JoinColumn(name = "attribuutlabel") })
private List<Label> labels;
Is it even possible in hibernate or should I validate my users input for having associated a label when they use this relation?
Thank you very much
Upvotes: 0
Views: 117
Reputation: 5399
What version of Java EE are you using?
If it's EE 6:
add a @NotNull
on the labels
if it's EE 5:
add @NotNull
include Hibernate Validator in the classpath of your app.
include bean validation (JSR 303) api in the classpath of your app.
Upvotes: 1