Re: RequestFactory: Get entity ID on success of persist
On Thursday, January 12, 2012 3:24:38 PM UTC+1, Tapomay Dey wrote: > > Hi, > I am using following code. > > Note: > request is of type ? extends RequestContext > entity is of type ? extends EntityProxy > > (request).persist().using(entity).fire( > new Receiver() { > @Override > public void onSuccess(Void unUsed) { > I need the entity ID generated in the DB here. > If I do entity.getId(); it returns null obviously. > As I don't know the ID here, I can't even refetch the persisted > entity. > You should be able to pass the entity.stableId() to RequestContext#find(). > The Receiver should have received the updated entity as arg to its > onSuccess. As Patrick said, make your persist() method return the entity, if that's what you want. Or you can make it return the entity ID if you prefer (smaller payload, but you have to make an additional request if you want to retrieve it; apply the 80/20 rule to choose between a smaller response payload or less requests). -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/xTzuj4Rs0MoJ. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: RequestFactory: Get entity ID on success of persist
in request is of type ? extends RequestContext add your own persist method that returns the newly created entity instead of void. The you receive it using Receiver instead of Receiver -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/aZ4ZeqV0XBIJ. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
RequestFactory: Get entity ID on success of persist
Hi, I am using following code. Note: request is of type ? extends RequestContext entity is of type ? extends EntityProxy (request).persist().using(entity).fire( new Receiver() { @Override public void onSuccess(Void unUsed) { I need the entity ID generated in the DB here. If I do entity.getId(); it returns null obviously. As I don't know the ID here, I can't even refetch the persisted entity. The Receiver should have received the updated entity as arg to its onSuccess. } }); How do I do it? Thanks, Tapomay. -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.