Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between owned one to many relationship and owned one to many bidirectional relationship(Google App Engine Java Api)

what is the difference between owned one to many relationship and owned one to many bidirectional relationship i read the article below but i don't understand it. Article

like image 789
Kerem Pekçabuk Avatar asked Jun 05 '10 17:06

Kerem Pekçabuk


1 Answers

The owned one to many bidirectional relationship just means that the children have a reference to the parent. For example, the child below can access the parent via persistentUser. If persistentUser didn't exist in the PersistentLogin class then it would not be bidirectional.

One-to-Many (PersistentUser.java - Parent):

@OneToMany(mappedBy = "persistentUser", cascade = CascadeType.ALL)
private Collection<PersistentLogin> persistentLogins;

Many-to-One (PersistentLogin.java - Child):

@ManyToOne(fetch = FetchType.LAZY)
private PersistentUser persistentUser;
like image 126
Taylor Leese Avatar answered Oct 31 '22 11:10

Taylor Leese