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<Void>() {
@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).