JPA 2.0 Hibernate 4.3 / 5.x java.lang.ClassNotFoundException:javax.persistence.NamedStoredProcedureQuery

时间:2017-04-14 22:24:58

标签: hibernate jpa jpa-2.0 hibernate-4.x hibernate-5.x

所以我遇到了前面提到的public class QANorthController : QAControllerBase { public QANorthController(NorthBusinessLayer businessLayer) : base(businessLayer) { } } public class QASouthController : QAControllerBase { public QASouthController(SouthBusinessLayer businessLayer) : base(businessLayer) { } } 。显然,在较新版本的hibernate中ClassNotFoundException依赖于org.hibernate.cfg.AnnotationBinder。如果您使用JPA 2.1,这是正确的行为。但是,当您需要JPA 2.0时,情况并非如此。

javax.persistence.NamedStoredProcedureQuery

1 个答案:

答案 0 :(得分:0)

您必须将hibernate-entitymanager添加到类路径中。这是一个空罐子但由于某种原因它使核心jar jpa 2.0兼容。

<dependency>
    <groupId>org.hibernate.javax.persistence</groupId>
    <artifactId>hibernate-jpa-2.0-api</artifactId>
    <version>1.0.1.Final</version>
</dependency>
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>5.2.10.Final</version>
    <exclusions>
        <exclusion>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.1-api</artifactId>
        </exclusion>
    </exclusions>
</dependency>