I have two classes in an owned one-to-many relationship. The parent is Map, and the child is POI (point of interest). I am trying to add a POI to an existing Map, but I get an exception when I try to persist my changes. Here are the two classes:
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Map {
    @PrimaryKey
     @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Long id;
    @Persistent(mappedBy = "map")
    private List<Poi> pois;
    public List<Poi> getPois() {
     return pois;
    }
}
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Poi {
    @PrimaryKey
     @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key id;
    @Persistent
    private Map map;
    public Map getMap() {
     return map;
    }
    public void setMap(Map map) {
     this.map = map;
    }
}
And here is how I am trying to use them:
PersistenceManager pm = PMF.get().getPersistenceManager();
// create a new POI
Poi poi = new Poi();
// find the Map by its ID
Map map = pm.getObjectById(Map.class, Long.decode(mapId));
// add the POI to the map
map.getPois().add(poi);
// persist!
pm.makePersistent(map);
pm.close();
The line "map.getPois().add(poi);" throws an exception saying "java.lang.ClassCastException: java.lang.Long" but doesn't tell me why. If I switch it around to "poi.SetMap(map);" it just fails silently. There is no error message and nothing happens.
Does anybody know how to correctly handle a one-to-many relationship in App Engine? Does anybody know of any good resources? Google's documentation has been mildly helpful but it is really lacking.