MountainClimb / datanucleus-appengine

Automatically exported from code.google.com/p/datanucleus-appengine
0 stars 0 forks source link

JDO @Element(serialized="true") Fails Exceptionally #215

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The JDO annotation @Element(serialized="true") should allow users to create a 
list of serializable objects.  Unfortunately, it fails with an exception 
("FooObject is not a supported property type.") when an entity with a populated 
list is persisted.  If the entity is persisted with an empty list, adding items 
to the list and persisting will fail silently.

public class FooObject implements Serializable 
{ 
    private final String name; 
    public FooObject(String name) 
    { 
        this.name = name; 
    } 
    public String toString() 
    { 
        return name; 
    } 
} 

@PersistenceCapable 
public class Entity 
{ 
    @Element(serialized="true") 
    List<FooObject> foos = new ArrayList<FooObject>(); 
    public Entity()
    {
        foos.add(new FooObject("Hello"));
        foos.add(new FooObject("World"));
    }
    public void addFoo(FooObject foo) 
    { 
        foos.add(foo); 
    }
    public List<FooObject> getFoos() 
    { 
        return foos; 
    } 
}

Original issue reported on code.google.com by laser...@gmail.com on 9 Jul 2010 at 3:09

GoogleCodeExporter commented 8 years ago
serialized on an element is to serialise the element into a join table. GAE 
(and indeed most non-RDBMS datastores) don't support such a thing. You need to 
specify the serialized on the @Persistent

Original comment by googleco...@yahoo.co.uk on 21 Jul 2011 at 7:10

GoogleCodeExporter commented 8 years ago
SVN trunk now throws an invalid metadata exception informing the user of this, 
advising them to mark the whole field as serialized

Original comment by googleco...@yahoo.co.uk on 21 Jul 2011 at 7:31