Hi,

If they don't belong to the same entity group, you will raise an
exception by trying to store 2 objects in a single transaction.

2 ways to handle that:

   a) you make Mobile belong to same entity group as Person so you'll
be able to store both in a single transaction. I understand in your
question that you can't go this way.
   b) you store one let's say Person in first transaction and during
this transaction, you start a task as part of the transaction: "You
can enqueue a task as part of a datastore transaction, such that the
task is only enqueued—and guaranteed to be enqueued—if the transaction
is committed successfully. Tasks added within a transaction are
considered to be a part of it and have the same level of isolation and
consistency." as said in 
http://code.google.com/appengine/docs/java/taskqueue/overview.html#Tasks_Within_Transactions

Hope it helps

didier



On Dec 15, 8:26 am, kartik kudada <kartik.kud...@gmail.com> wrote:
> Can we store two unowned objects(one to many) in datastore in a single
> transaction.
> For example -  We have
>
> public class Person {
> @PrimaryKey
> �...@persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
> private Long id;
>
> @Persistent
> private String name;
>
>         @Persistent
>  private List<Key> mobileIds =  new ArrayList<Key>();
>
>    //....
>   //.....
>   }
>
> public class Mobile {
>
>         �...@primarykey
> @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
>  private Key mobileId;
>
>   // ...
>  //....
>
> }
>
> I want to store these two objects in datastore in single transaction so that
> relation  can be made in between both objects.
> Tell me if any other solution is there ?

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to