I cannot find any documentation on the appropriate way to make many-to-many relationships between objects using Objectify in the Google App Engine.
Can someone explain how to do this? Do I need to create a new class for this? How effective is it?
What queries do you need for support?
The simplest solution:
@Entity public class StoredObject { @Id private Long id; private List<Long> relatedIds; }
then with a StoredObjectyou can call objectify.get(StoredObject.class, storedObject.getRelatedIds())to get all associated identifiers.
StoredObject
objectify.get(StoredObject.class, storedObject.getRelatedIds())
, . ( ), - !
Objectify. - , . , , A B, . , :
Class Link{ Key<?> master; key<?> slave; public Link(){ } public setLink(Entity master, Entity slave){ //initialize } }
Link . " " " "
Objectify 4.0:
@Entity @Index public class Module { @Id private Long id; private String name; @Load private List<Ref<Template>> templates; public List<Template> getTemplates() { List<Template> templates = new ArrayList<Template>(); for (Ref<Template> temp : this.templates) { templates.add(temp.get()); } return templates; } public void setTemplates(List<Template> templatesParm) { List<Ref<Template>> templates = new ArrayList<Ref<Template>>(); for (Template temp : templatesParm) { templates.add(Ref.create(temp)); } this.templates = templates; }
- ; , A "" B-s, :
: B A. A0 , B, Bs, A0.
NoSQL/ObjectStore: make A , () B-s. , B-s ( GAE/Java .)
. ObjectStore . , , A B Entity Group, Ancestor (, , ), Bs, A. A Bs , (, , ), B, , B, : https://developers.google.com/appengine/articles/transaction_isolation
( ) . , , , , . , , .
-: , ; : / . ( ) " " ( ): http://settlement.arc.nasa.gov/CoEvolutionBook/SPACE.HTML#There ... - GAE. join, .