物件的關係
owned(可看做是composited的關連,也就是強關聯)
單向一對一關係(unidirectional one-to-one ): 僅只要在Parent中放Child object 即可。
雙向一對一的關系bidirectional one-to-one:在child中加入parent的物件並給annotation( @Persistent(mappedBy = "contactInfo"))其中contactInfo為單向一對一中parent所放置child的field name.
在物件關系中,需注意
. If you do not access the child object on a parent object, the entity for the child object is never loaded. If you want to load the child, you can either "touch" it before closing the PersistenceManager 。
or using
@Persistent(defaultFetchGroup = "true") private ContactInfo contactInfo;
※由於Entity group 的關聯是在create object時建立的,所以在建立物件時,請於關聯中建立,而不要分別建立物件後,再給關係。
一對多的關系Owned One-to-Many Relationships
與一對一類似,僅是替換成Collection of the related class。
而雙向的的方式也是child中加入parent的物件中利用@Persistent(mappedBy ="")
App Engine does not support join queries(can query a property of an embedded class)
※若是collection要排序,則加入annotation, @Order(extensions = @Extension(vendorName="datanucleus", key="list-ordering", value="state asc, city asc"))
Unowned One-to-One
Many-to-Many Relationships
transactions
transactions
沒有留言:
張貼留言