GWT Gilead (JPA configuration)

六眼飞鱼酱① 提交于 2020-01-20 09:14:24

问题


From the Gilead official site:

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

I Use JPA, do i have to do something different?


回答1:


If you're using JPA with Hibernate, you can use HibernateJpaUtil like this:

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

If you're using JPA with another implementation than Hibernate, you're probably currently out of luck - or you'd have to implement IPersistenceUtil yourself.

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



来源:https://stackoverflow.com/questions/5567444/gwt-gilead-jpa-configuration

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!