I think you may need a transaction, http://xrl.in/411x

PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
    tx.begin();
    
    {users code to persist objects}
    
    tx.commit();
}
finally
{
    if (tx.isActive())
    {
        tx.rollback();
    }
}
pm.close();


Saurabh Mehta wrote:
> Hi,
> 
> How can we get the value of a newly created key (system-generated), as
> soon as after we save the entity.
> 
> In other words, is it possible to do something like this?
> 
> @PrimaryKey
> @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
> private Key key;
> .
> .
> .
> .
> public Key save(OBJ obj)   {
>          PersistenceManager pm = PMF.get().getPersistenceManager();
>          pm.makePersistent(obj);
>          return obj.getKey();
> }
> 
> --
> 
> You received this message because you are subscribed to the Google Groups 
> "Google App Engine for Java" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/google-appengine-java?hl=en.
> 
> 

--

You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.


Reply via email to