Hello,
I guess your problem is the behavior of serialized fields (including
collections of them, as far as I know), which is explained in Max
Ross's post.
Or something related to that.

Anyway, some property fields are marked as "updated" and hence saved
in the datastore only if you update the reference to the field, and
they're not updated if you just use modifiers to operate on them.
In practice, something like

 ArrayList<Foo> list = "retrieve from datastore"
list.add(Foo foo)
close persistence manager

Does not modify the list in the datastore, so if it's saved as an
empty list at creation it remains empty.
Doing

 ArrayList<Foo> list = "retrieve from datastore"
 ArrayList copy = new ArrayList(list);
 copy.add(Foo foo)
 list = copy;
close PM

Usually makes everything work, since the original list field is marked
as "updated" and persisted.
As far as I know this is true both for serialized fields and for many
collections.

Regards
Lorenzo

On Jul 7, 1:28 pm, laserjim <[email protected]> wrote:
> Hello Lorenzo,
>
> Thanks, but perhaps my question wasn't clear.  I'm trying to make a
> list of serialized objects, NOT a serialized list of objects.
>
> For instance, assuming FooObject implements Serializable...
>
> @Element(serialized="true)
> List<FooObject> foos = new ArrayList<FooObject>();
>
> Unfortunately, the list is always empty.  Not quite sure why.
>
> Thanks!
>
> On Jul 7, 2:59 am, "l.denardo" <[email protected]> wrote:
>
> > If you are using a serialized field you must add the serialized="true"
> > clause to your annotation
>
> > @Persistent(serialized="true")
> > MySerializableObject serializable;
>
> > Also notice that JDO does not automatically detect if you update only
> > the inner fields of the object you save, so you must substitute it
> > with a copy to have it persisted.
> > See this post for a very good overview and an explanation of the fact
> > above:
>
> >http://groups.google.com/group/google-appengine-java/browse_thread/th...
>
> > Regards
> > Lorenzo
>
> > On Jul 7, 1:33 am, laserjim <[email protected]> wrote:
>
> > > Hello,
>
> > > I'm still trying to persist a list of serializable objects. I would
> > > expect this to be a standard collection as described 
> > > here:http://code.google.com/appengine/docs/java/datastore/dataclasses.html...
>
> > > FooObject is serializable, but my attempt gave me an exception:
> > > FooObject is not a supported property type.
>
> > > Everything works as expected if I replace my serializable class
> > > (FooObject) with String.
>
> > > How can I persist my list of FooObjects using JDO?
>
> > > Thanks!

-- 
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.

Reply via email to