Thanks Andrey, that works perfectly. I wasn't understanding the
example in the docs about this:

  http://code.google.com/appengine/docs/java/datastore/transactions.html

section titled "Creating Entities With Entity Groups".

Your example makes it clear,

Thanks

On Apr 27, 6:04 am, ailinykh <[email protected]> wrote:
> define Cow as
>
> class Cow {
> @PrimaryKey
>     @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
>     private Key id;
>
>         @Persistent
>     @Extension(vendorName="datanucleus", key="gae.parent-pk",
> value="true")
>     private Key farmKey;
>
> }
>
> If you set farmKey to farm id then both farm and cow will be in the
> same entity group.
>
> this code should work:
>
> tx.begin()
>
> Farm f = getFarm();
> Cow c = new Cow();
> c.setFarmKey(f.getId());
> f.incCowCounter();
> pm.makePersistent(c);  //if you need to know new cow id.
>
> tx.commit();
>
> Andrey
>
> --
> 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 
> athttp://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