Hello,
I'm facing a problem with JDO persistence of a collection. I save an
object with a persistent ArrayList of Keys, retrieve the object and
set the collection to a new value. Change is not persisted.

Some code:
@PersistenceCapable
public class ComplexDatastoreCalendar {
@Persistent
        private ArrayList<Key> calendarsToLink;
@Persistent(serialized="true")
        private Map<Key, Integer> linkOrderIndex;
public void setCalendarsToLink(ArrayList<Key> newKeys, Map<Key,
Integer> newLinkOrderIndexes){
                ArrayList<Key> toSubstitute = new ArrayList<Key>();
                for (Key key : newKeys){
                        toSubstitute.add(key);
                }
                calendarsToLink = new ArrayList<Key>(toSubstitute);
                linkOrderIndex = new HashMap<Key, Integer>(newLinkOrderIndexes);
        }
}

In my handler I create a ComplexDatastoreCalendar with a value for
both fields, close persistenceManager, get a new PM instance and do

     ComplexDatastoreCalendar converted =
pm.getObjectById(ComplexDatastoreCalendar.class, convertedKey);
                                //get the list of keys in this calendar
                                ArrayList<Key> oldKeys = new
ArrayList<Key>(converted.getCalendarsToLink());
                                if (oldKeys.isEmpty()){
                                        continue;
                                }
                                ArrayList<Key> newKeys = new ArrayList<Key>();
                                Map<Key, Integer> oldIndexes = 
converted.getLinkOrderIndex();
                                Map<Key, Integer> newIndexes = new HashMap<Key, 
Integer>();
                                for (Key old : oldKeys){
                                        //retrieve this value from a
map
                                        newKeys.add(oldKeysToNew.get(old));
                                        newIndexes.put(oldKeysToNew.get(old), 
oldIndexes.get(old));
                                }
                                converted.setCalendarsToLink(new 
ArrayList<Key>(newKeys),
newIndexes);
                                JDOHelper.makeDirty(converted, 
"calendarsToLink");
                                pm.makePersistent(converted);

After this call, I close PM and go.
No change is persisted to field calendarsToLink, even if the field's
value (both content and reference to object) changes, AND the field is
explicitly marked dirty.

DataNucleus log does not seem to help:

Oct 22, 2010 10:46:33 AM
org.datanucleus.store.appengine.DatastorePersistenceHandler get
FINE: Getting entity of kind ComplexDatastoreCalendar with key
ComplexDatastoreCalendar(700)
Oct 22, 2010 10:46:33 AM org.datanucleus.sco.backed.ArrayList <init>
FINE: Object
"it.miriade.planner.server.entities.calendars.complexdatastorecalen...@1dd2910"
field "calendarsToLink" is replaced by a SCO wrapper of type
"org.datanucleus.sco.backed.ArrayList" [cache-values=true, lazy-
loading=false, queued-operations=false, allow-nulls=false]
Oct 22, 2010 10:46:33 AM org.datanucleus.sco.backed.ArrayList
initialise
FINE: Object
"it.miriade.planner.server.entities.calendars.complexdatastorecalen...@1dd2910"
field "calendarsToLink" is having its SCO wrapper initialised with a
container with 2 values
Oct 22, 2010 10:46:33 AM
it.miriade.planner.server.handlers.calendars.ListCalendarsHandler
secureExecute
WARNING: Read oldKeys [DataStoreCalendar(444), DataStoreCalendar(448)]
Oct 22, 2010 10:46:33 AM
it.miriade.planner.server.entities.calendars.ComplexDatastoreCalendar
setCalendarsToLink
WARNING: Reference check: false
Oct 22, 2010 10:46:33 AM org.datanucleus.ObjectManagerImpl
persistObjectInternal
FINE: Making object persistent :
"it.miriade.planner.server.entities.calendars.complexdatastorecalen...@1dd2910"

Any help about this will be appreciated. I'm using GAE 1.3.7 (cannot
switch to 1.3.8 because I need to test a data transformation, and
1.3.8 loses datastore content).

Thanks to everybody
Lorenzo

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to