ObjectDatastore.load() returns null

18 views
Skip to first unread message

powwow

unread,
May 9, 2013, 8:17:05 PM5/9/13
to twig-p...@googlegroups.com
I can't seem to figure this out.  What I am trying to do is very trivial and it doesn't load.

Here are my data classes:

public class Screencap {
@Id public Long id;
public String blobkey;
@Activate(0) @Child public List<LinkData> linkDataList;
}

public class LinkData {
@Id public Long id;
@Activate(0) @Parent public Screencap screencap;
public String txt;
@Index public Date dateCreated;
}

This works and I get the right object:

  ObjectDatastore datastore = OD.get();
  return datastore.load(Screencap.class, screencapId);

However, this returns null!

  ObjectDatastore datastore = OD.get();
  return datastore.load(LinkData.class, linkDataId);  //There is indeed a LinkData row with an id in the GAE datastore but it returns null!

What am I doing wrong?  Also this code below work fine:

  ObjectDatastore datastore = OD.get();
  Screencap screencap = datastore.load(Screencap.class, screencapId);
  List<LinkData> linkDataItems = datastore.find()
.type(LinkData.class)
.ancestor(screencap)
.addSort("dateCreated", SortDirection.DESCENDING)
.returnAll()
.now();

powwow

unread,
May 10, 2013, 5:01:32 PM5/10/13
to twig-p...@googlegroups.com
Ok, it took me two days to figure it out. :P  Here it is:

LinkData linkData = datastore.load().type(LinkData.class).id(linkDataId).parent(screencap).now();
Reply all
Reply to author
Forward
0 new messages