I hope this is the right place for this type of problem.
An Object of my class Movie
can have several keywords
( like ‘fight club’, ‘brad’, ‘fincher’), and be part of different categories
(like ‘Drama’, ‘Best Movies Ever’) I implemented them as ManyToMany:
@OneToMany(targetEntity = Keyword.class,fetch=FetchType.EAGER)
private Set<Keyword> keywords;
@OneToMany(targetEntity = MovieCategory.class, fetch=FetchType.EAGER)
private Set<MovieCategory> movieCategories;
Somehow I don’ think, this is not the correct relationshipmodel, how would you implement this? Right now hibernate wont allow me to fetch.eager. fetch.lazy is okay. I found this link http://www.mkyong.com/hibernate/hibernate-many-to-many-relationship-example-annotation/ but it didn’t answered my question.
2
Why not use @ManyToMany?
If different movies have different keywords and a keyword can be related to different movies then that requires @ManyToMany. The same goes for categories.
0