我正在编写一个使用GWT、Hibernate和Google Guice (使用GIN)的相当简单的应用程序。我想要做的是使用外部管理器来管理事务(就像在Spring中使用@Transactional ),而不是使用EntityManager#getTransaction。我试过使用@Transactional,但它似乎对我不起作用。
我已经使用Providers注入了EntityManager,如下所示:
/* import stuff */
public class DbProvider implements Provider<EntityManager> {
public EntityManager get() {
EntityManagerFactory emf = Persistence.createEntityManagerFactory("persdb");
return emf.createEntityManager();
}
}在手动管理事务时,它似乎工作正常。我想让事务自动管理,也是为了用DBUnit进行自动化测试。
有人知道怎么解决这个问题吗?
发布于 2011-03-13 17:47:10
在Guice requires three things中使用@Transactional
guice-persist.jar @Transactional方法的对象必须由Guicehttps://stackoverflow.com/questions/5287985
复制相似问题