Wednesday, June 29, 2011

RequestFactory - persist method that returns the saved Entity.

So, still trying to fully understand the RequestFactory, I made myself
a small app to test having my persistence code in the entity itself.
(I have been previously working off the TurboManage
objectify+requestfactory sample, thanks David, its been very useful!)

I have an Entity called Parent, which has this method:

public Parent persistAndReturn() {
ObjectifyDao dao = new ObjectifyDao();
this.aBool = true;
Key<Parent> key = dao.ofy().put(this);
return dao.ofy().get(key);

In my App's RequestFactory interface, I have this:

interface ParentRequestContext extends RequestContext {
InstanceRequest<ParentProxy, Void> persist();
InstanceRequest<ParentProxy, ParentProxy> persistAndReturn();
ParentRequestContext getParentRC();

Then when I want to create and persist a new Parent object, I do this...

ParentRequestContext rc = rf.getParentRC();
ParentProxy proxyObj = rc.create(ParentProxy.class);
(.. set some properties.. )

Request<ParentProxy> fetchRequest = rc.persistAndReturn().using(proxyObj); Receiver<ParentProxy>(){
(... onSuccess Handler.. )

However I get the 'autobean has been frozen' error (stack trace: )
Its clear from the stacktrace and other debug messages that the object
is persisted, but returning it fails.


Is this possible? Is it desirable?

Also, if we look at the last line,, we could also
do instead of it, and get the same result.. Are we doing
the exact same operation when we call either 'fire' method?


You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment