Monday, August 24, 2015

Re: RequestFactory - update entity

The first question that comes to mind is: where does 'object' come from? (and why is it frozen)

On Monday, August 24, 2015 at 9:10:30 PM UTC+2, Manuel wrote:
Hi everyone,

Im using the requestFactory and want to update an entity. The problem is, its frozen.

I get an entityProxy passed, were I like to update 1 value. The problem is, when I try to edit it with a new Request, it fails, cause the proxy is frozen.

I found this: http://stackoverflow.com/questions/7479779/gwt-autobean-frozen-when-saving-graph

It says, I got to get a new entityProxy from the server.

This would take 1 request to receive a "fresh" entityProxy and another for the update... I was wondering, if there is a better way to do this? Or whats the proper way to update a entity with just 1 request?
Is there a way to actually create a new entityProxy on the client that updates an existing entity without loading it from the server?

Thats what I tried:
               PersonRequest request = AppManager.getRequestFactory().personRequest();
               
PersonProxy proxy = request.create(PersonProxy.class);

               
               proxy
.setSalary(0);
               proxy
.setId(object.getId()); // Copy values of passed object
               proxy
.setVersion(object.getVersion());              
               
               request
.persist(proxy).fire(new Receiver<PersonProxy>()


Copy all values ends in hibernate Exception for detached entity passed to persist.

Thanks in advance.

Regards

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment