【问题标题】:How to use Hibernate 4.3 in combination with the JPA 2.1 EntityManager?如何结合使用 Hibernate 4.3 和 JPA 2.1 EntityManager?
【发布时间】:2014-06-28 04:39:44
【问题描述】:

我一直想知道为什么 Hibernate 4.3 社区文档没有描述将 Hibernate 4.3 与 JPA 2.1 实体管理器一起使用。 那么,他们是否有任何具体原因不将 JPA 实体管理器与 Hibernate 4.3 一起使用,我的主要问题是如何将 JPA EntityManager 与 Hibernate 4.3 结合使用?

【问题讨论】:

    标签: java hibernate jpa entitymanager


    【解决方案1】:

    嗯,看dependencies of hibernate-entitymanager 4.3

    这个神器依赖于...

    org.hibernate.javax.persistence hibernate-jpa-2.1-api

    因此,hibernate EntityManager 是 JPA 2.1 的实现。如果您的项目使用 Hibernate 的 4.3.x 版本,它使用 JPA 2.1,即使您没有意识到。因此,您应该能够使用 JPA 2.1 中指定的所有功能。

    【讨论】:

      【解决方案2】:

      相反,JBoss wants you to use EntityManager instead of Session。这样做的文档已经移动。你可以找到它here

      此外,任何有关 JPA 2 的书籍(例如 Pro JPA 2)都将 100% 适用于 Hibernate。

      【讨论】:

        猜你喜欢
        • 2014-05-27
        • 1970-01-01
        • 2014-06-12
        • 1970-01-01
        • 2011-12-26
        • 1970-01-01
        • 2017-09-30
        • 2020-03-16
        • 1970-01-01
        相关资源
        最近更新 更多