Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 我可以将@Transactional from Guice与Google App Engine';谁的数据存储?_Java_Google App Engine_Transactions_Google Cloud Datastore_Guice - Fatal编程技术网

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);
    }
}