Hi, First of all, thanks for posting, it really helps me.
objectuser : Good post and the link was really nice. Albert Attard : Thanks for the examples, it shows that you have to wright lots of code to manage your own relationships (which I was trying to avoid). leszek: This is what I did and I was trying to avoid to handle persistence issues as much as I could. I will re-model and start over and see how I should go on. Thanks. FF On Sep 1, 9:52 am, leszek <[email protected]> wrote: > You can follow something like that > > class Parent { > .... > @Persistent > private List<Long/Key> childList; > > // non Persistent > private List<Child> list; > ... > > } > > class Child { > > �...@primarykey > private Long/Key key; > ... > > } > > // before save Parent > private void beforeSave(EntityManager em,Parent pa) { > if (pa.getList() != null) { > List<Long> chList = new ArrayList<Long>(); > for (Child ch : pa.getList) { > pm.makePersistent(ch); > pm.flush(); > chList.add(ch.getKey()); > } > pa.setChildList(chList); > } > } > > private void afterLoad(EntityManager em,Parent pa) { > List<Child> chList = new ArrayList<Child>(); > for (Long key : pa.getChildList()) { > Child ch = pm.getObjectById(Child.class,key); > chList.add(ch); > } > pa.setList(chList); > } > > PersistenManager pm; > .... > > // main service > Parent pa = pm..getObjectById(...) > afterLoad(pm,pa); > ... > ... > beforeSave(pm,pa); > pm.makePersistent(pa); > > List<Parent> pList = pm.queryExecute(); > for (Parent pa : pList) { > afterLoad(pm,pa); > } > ... > // etc > > In order to avoid repeating the same beforeSave and afterLoad for all > Entity classes having "onowned" relationship you can apply Annotation > and, by the use of reflection, develop generic approach for all > classes having this feature. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en -~----------~----~----~----~------~----~------~--~---
