RequestFactory Refractory Long Id into String Id, so I can use App Engine Keys??

25 views
Skip to first unread message

Brandon Donnelson

unread,
Oct 19, 2011, 2:58:42 PM10/19/11
to google-we...@googlegroups.com

I think the RequestFactory ID system should be a String and not a Long so we can use child collections on App Engine easily. App Engine keys can be reflected as Entity(1)/Entity(2)/Entity(3)... . I would think this wouldn't require a Key serialization routine. 

Any Thoughts?

Brandon Donnelson

Jens

unread,
Oct 19, 2011, 3:33:54 PM10/19/11
to google-we...@googlegroups.com
I dont know App Engine but if you implement a Locator for your entities you can use any type as Id. Works pretty well (I have a sample project that uses String UUIDs as Id for entities).

-- J.

Brandon Donnelson

unread,
Oct 19, 2011, 3:37:34 PM10/19/11
to google-we...@googlegroups.com
I just figured I ship the Ids as string, and its working fine. I noticed the source was not particular to what type of ID it is. So I'll serialize the App Engine key. I suppose Long has more type safety. 

Thanks for commenting to that helps Jens. 

Brandon

Brandon Donnelson

unread,
Oct 19, 2011, 4:21:14 PM10/19/11
to google-we...@googlegroups.com
RequestFactory now works good with AppEngine if your Id's are Keys in Strings.

This is what I end up doing:
 public void setId(String id) {
   
if (id == null) {
     
return;
   
}
    key
= KeyFactory.stringToKey(id);
 
}
 
public String getId() {
   
String id = null;
   
if (key != null) {
      id
= KeyFactory.keyToString(key);
   
}
   
return id;
 
}
Reply all
Reply to author
Forward
0 new messages