0

So I ran into the aforementioned ClassNotFoundException. Apparently in the newer versions of hibernate org.hibernate.cfg.AnnotationBinder is dependent on javax.persistence.NamedStoredProcedureQuery. This is correct behaviour if you are using JPA 2.1. However this is not the case when you need 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>
pjanssen
  • 1,065
  • 13
  • 35

1 Answers1

0

You have to add hibernate-entitymanager to your classpath. This is an empty jar but for some reason it makes the core jar jpa 2.0 compliant.

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <version>${hibernate.version}</version>
</dependency>
pjanssen
  • 1,065
  • 13
  • 35
  • Since 5.2, `hibernate-entitymanager` simply redirects to `hibernate-core`. – coladict Apr 18 '17 at 06:45
  • You are correct but I found that if the entitymanager package is not on the classpath the core module will use the JPA 2.1 interface. – pjanssen Apr 18 '17 at 06:52
  • 1
    I'm pretty sure you just ended-up using the 2.1 interface anyway, or it will still crash with the ClassNotFoundException. Anyway you shouldn't forcefully downgrade with that exclusion as you tried. That was the real problem. – coladict Apr 18 '17 at 06:58