• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

one to many bidirectional?

 
Tony Smith
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't think of any scenario where one to many bidirectional would make sense. Can someone enlighten me?
 
Paul Michael
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The said relationship will be useful suppose you want to get the Director of a Movie or all the Movies for a particular Director.

class Movie

@ManyToOne
Director director


class Director

@OneToMany(mappedBy=director)
Collection<Movie> movies
 
Jarrod Marshall
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
True, but if you need to serialize an object chain like this you get a stack overflow because JPA does not support unidirection OneToMany without a join table.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic