问题描述
拥有一对多关系和
拥有一对多双向关系之间的区别是什么
我阅读了下面的文章,但我不明白。
what is the difference between owned one to many relationship andowned one to many bidirectional relationshipi read the article below but i don't understand it.Article
一对多的双向关系只是意味着孩子有一个对父母的引用。例如,下面的孩子可以通过persistentUser访问父级。如果persistentuser不存在于PersistentLogin类中,那么它将不是双向的。
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.
一对多(PersistentUser.java - 父类):
One-to-Many (PersistentUser.java - Parent):
@OneToMany(mappedBy = "persistentUser", cascade = CascadeType.ALL)
private Collection<PersistentLogin> persistentLogins;
多对一(PersistentLogin.java - Child):
Many-to-One (PersistentLogin.java - Child):
@ManyToOne(fetch = FetchType.LAZY)
private PersistentUser persistentUser;
这篇关于拥有一对多关系并拥有一对多双向关系(Google App Engine Java Api)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!