来自Gilead官方网站:
Note that you still have to properly initialize PersistentBeanManager with associated PersistenceUtil, proxy store and possibly class mapper. This must be done before any remote call, in Remote Service constructor or in inherited "init" method (do not forget to call super.init() !):
public UserRemoteImpl()
{
HibernateUtil hibernateUtil = new HibernateUtil(MyApplicationHibernateUtil.getSessionFactory());
PersistentBeanManager persistentBeanManager = GwtConfigurationHelper.initGwtStatelessBeanManaer(hibernateUtil);
setBeanManager(persistentBeanManager);
}
我使用JPA,我需要做一些不同的事情吗?
最佳答案
如果您将 JPA 与 Hibernate 一起使用,则可以像这样使用 HibernateJpaUtil
:
String PERSISTENCE_UNIT_NAME = "...";
EntityManagerFactory emf =
Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
HibernateJpaUtil hibernateJpaUtil = new HibernateJpaUtil();
hibernateJpaUtil.setEntityManagerFactory(emf);
PersistentBeanManager persistentBeanManager =
GwtConfigurationHelper.initGwtStatelessBeanManager(hibernateJpaUtil);
setBeanManager(persistentBeanManager);
如果您将 JPA 与 Hibernate 之外的其他实现一起使用,那么您目前可能不走运 - 或者您必须自己实现 IPersistenceUtil
。
http://noon.gilead.free.fr/gilead/index.php?page=overview :
even if Hibernate is the only one currently supported, OpenJPA and EclipseLink supports is planned
关于java - GWT Gilead(JPA 配置),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5567444/