I am update the collection field of a detached object and persisting
it. Upon view the object i see that it still has the old items in its
collection.

@PersistenceCapable(detachable="true")
@FetchGroup(name="fet_num", member...@persistent(name="numbers")})
public class DirectoryBean {

        public DirectoryBean(String nameOfCity, ArrayList<NumberBean>
numbers) {
                super();
                this.nameOfCity = nameOfCity;
                this.numbers = numbers;
        }

        @Persistent
        @PrimaryKey
        private String nameOfCity;

        @Persistent
        @Element(dependent = "true")
        private ArrayList<NumberBean> numbers;


@PersistenceCapable(detachable = "true")
@FetchGroup(name="fet_own", member...@persistent(name="owners")})
public class NumberBean {

        public NumberBean(String areaCode, String num) {
                super();
                this.areaCode = areaCode;
                this.num = num;
                this.owners = new ArrayList<OwnerBean>();
        }

        @PrimaryKey
        @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
        private Key key;

        @Persistent
        private String areaCode;

        @Persistent
        private String num;

        @Persistent
        @Element(dependent = "true")
        private ArrayList<OwnerBean> owners;


@PersistenceCapable(detachable = "true")
public class OwnerBean {

        public OwnerBean(String fname, String lname) {
                super();
                this.fname = fname;
                this.lname = lname;
        }

        @PrimaryKey
        @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
        private Key key;

        @Persistent
        private String fname;

        @Persistent
        private String lname;



PersistenceManager pm = PMF.get().getPersistenceManager();
                pm.getFetchPlan().addGroup("fet_own").addGroup("fet_num");
                pm.getFetchPlan().setMaxFetchDepth(-1);
        
pm.getFetchPlan().setDetachmentOptions(pm.getFetchPlan().DETACH_LOAD_FIELDS);
                DirectoryBean dirBeanInstance,detachedDirBeanInstance=null;
                try{
                        Key k = 
KeyFactory.createKey(DirectoryBean.class.getSimpleName(),
"lake City");
                        dirBeanInstance = 
pm.getObjectById(DirectoryBean.class,k);
                        detachedDirBeanInstance = 
pm.detachCopy(dirBeanInstance);
                }catch(Exception e)
                {
                        e.printStackTrace();
                }finally
                {
                        pm.close();
                }

                 ArrayList<NumberBean> newNumBeans = new
ArrayList<NumberBean>();
                newNumBeans.add(new NumberBean("555", "7777777"));
                detachedDirBeanInstance.setNumbers(newNumBeans);

                pm = PMF.get().getPersistenceManager();
                try{
                        pm.makePersistent(detachedDirBeanInstance);
                }catch(Exception e)
                {
                        e.printStackTrace();
                }finally
                {
                        pm.close();
                }

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appeng...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to