Java 我可以将@Transactional from Guice与Google App Engine';谁的数据存储?
我可以这样做吗?即使我没有使用Java 我可以将@Transactional from Guice与Google App Engine';谁的数据存储?,java,google-app-engine,transactions,google-cloud-datastore,guice,Java,Google App Engine,Transactions,Google Cloud Datastore,Guice,我可以这样做吗?即使我没有使用ds.get(tx,key)和ds.put(tx,key),它仍然是一个事务吗 我不习惯Guice,但像其他依赖项注入框架一样,我猜您必须在模块配置中声明某种TransactionManager? 在这种情况下,它并不存在,或者至少没有被谷歌广告。 也许你会在社区中找到你需要的,看看GitHub。。。但我再次高度怀疑Guice是否支持低级别数据存储的开箱即用。 不过,您可能在Guice中有一些JPA支持 或者您可以开发自己的事务管理器。。。 我已经用Spring开发
ds.get(tx,key)
和ds.put(tx,key)
,它仍然是一个事务吗
我不习惯Guice,但像其他依赖项注入框架一样,我猜您必须在模块配置中声明某种TransactionManager? 在这种情况下,它并不存在,或者至少没有被谷歌广告。 也许你会在社区中找到你需要的,看看GitHub。。。但我再次高度怀疑Guice是否支持低级别数据存储的开箱即用。 不过,您可能在Guice中有一些JPA支持 或者您可以开发自己的事务管理器。。。 我已经用Spring开发了自己的@DatastoreTransactional注释,但不幸的是在生产运行时使用Spring AOP失败,请参见:
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);
}
}