質問は:ds.put(employee)はトランザクションで発生しますか?または、外部トランザクションは、saveRecord(..)のトランザクションによって消去/オーバーライドされますか?
- forループのある時点(たとえばi == 5)で行datastore.put(..)でエラーがスローされると、同じ行で発生した以前のプットはロールバックされますか?
- saveRecord(..)で発生するプットについてはどうでしょうか。それらはロールバックされないと思います。
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService()
トランザクションtxn=datastore.beginTransaction();
試す {
for(int i = 0; 1 <10; i ++){
キーemployeeKey=KeyFactory.createKey( "Employee"、 "Joe");
エンティティemployee=datastore.get(employeeKey);
employee.setProperty( "vacationDays"、10);
datastore.put(employee);
エンティティemployeeRecord=createRecord( "record"、employeeKey);
saveRecord(employeeRecord);
}
txn.commit();
} ついに {
if(txn.isActive()){
txn.rollback();
}
}
public void saveRecord(Entity entity){
datastore.beginTransaction();
試す {
//ここでいくつかのロジックを実行し、アクティビティを削除してtxnをコミットします
datastore.put(entity);
} ついに {
if(datastore.getCurrentTransaction()。isActive()){
datastore.getCurrentTransaction()。rollback();
}
}
}