2

If i create a proxy object on the client side and persist it, shouldn't my proxy object after it is persisted on the server side be automatically updated with the generated id?

For example this code prints out "null".

final MyRequestFactory requestFactory = clientFactory.getRequestFactory();
final TestRequest request = requestFactory.testRequest();

final TestProxy myTestObj = request.create(TestProxy.class);

Request<Void> createReq = request.persist.using(myTestObj);

createReq.fire(new Receiver<Void>() {
    @Override
    public void onSuccess(Void nothing) {
        System.out.println(myTestObj.getId());
    }
});

Or do i have to change my code so that the persist method returns my object again?

4

1 回答 1

2

是的,你是对的,调用persist()不会改变客户端中的代理对象,你必须去服务器再次获取对象。

正常的方法是persistAndReturnSelf()在你的Request.

request.persistAndReturnSelf(myTestObj).fire(new Receiver<TestProxy>()) {
   ...
}
于 2013-06-09T07:02:10.787 回答