Answer the question
In order to leave comments, you need to log in
How to set a limit on the number of links in Hibernate?
@ManyToMany(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY)
@JoinTable(name = "movies_directors",
joinColumns = @JoinColumn(name = "movie_id"),
inverseJoinColumns = @JoinColumn(name = "director_id"))
Set directors = new HashSet();
This is a description of a many-to-many relationship using annotations. A movie can have multiple directors - a director can have multiple movies. If I want each movie to have between 1 and 4 directors, how do I set this limit?
Answer the question
In order to leave comments, you need to log in
Add a setter to the entity class that controls the addition of elements to the field directors
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question