I have tried to insert/update multiple entites on a single transaction but no avail. It always throws IllegalArgumentException.
I wanted to do something like this.
Transaction tx = pm.currentTransaction();
tx.begin();
for(int i=0;i<10;i++) {
SampleEntity entity = new SampleEntity(i);
pm.makePersistent(entity);
}
tx.commit();
If this is not possible, is there a workaround to make it work? 开发者_StackOverflow中文版Thanks.
The docs on Transactions should be helpful here, especially the section on Entity Groups.
Entity groups tell App Engine to store multiple entities in the same node of the datastore -- otherwise, a transaction would require tons of cross-node communication and be nearly impossible to get right.
Entity groups are primarily used for parent-child relationships, so that a child entity can be updated in the same transaction as is parent.
精彩评论