我可以做这样的事情吗?即使我没有使用ds.get(tx, key)
and ,它仍然是交易ds.put(tx, key)
吗?
public class MyClass {
private final DatastoreService ds;
@Inject
public MyClass(DatastoreService ds) {
this.ds = ds;
}
@Transactional
public void plusOne() {
Key someKey;
Entity thing = ds.get(someKey);
int newValue = thing.getProperty("prop") + 1;
thing.setProperty("prop", newValue);
ds.put(thing);
}
}