java - GWT Gilead(JPA 配置)

标签 java gwt jpa gilead

来自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/

相关文章:

java - 使用涉及日期限制的 JPA2 通过 EntityManger 重写 Hibernate SessionFactory 查询

java - 使用 Spring transactionManager 进行集成测试

java - WebDriver 无法在 Firefox 4 及更高版本上运行测试

Java 图形仅在按钮单击时绘制

java - GWT mvp 示例项目 : cannot call method of presenter

java - 开始 GWT 和 Java - 从 LAMP 背景出发时,哪条路最好?

hibernate Java 8 ZonedDateTime

java - 无法将类型 'java.lang.String' 的值转换为所需类型 'java.lang.Integer' 在 jpa spring 中

java - shape.intersects 函数 - 行为

java - Android 中的 jdbc 问题 - 无法连接到数据库