Home >Java >javaTutorial >Why Does Upgrading Hibernate from 4.2.5 to 4.3.0 Cause a NoSuchMethodError for javax.persistence.Table.indexes()?

Why Does Upgrading Hibernate from 4.2.5 to 4.3.0 Cause a NoSuchMethodError for javax.persistence.Table.indexes()?

Linda Hamilton
Linda HamiltonOriginal
2024-11-26 13:12:121039browse

Why Does Upgrading Hibernate from 4.2.5 to 4.3.0 Cause a NoSuchMethodError for javax.persistence.Table.indexes()?

NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;

Problem:

Upon upgrading from Hibernate 4.2.5 to 4.3.0, an exception has been raised:

NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;

This issue persists with Hibernate versions 4.2.6-4.2.8, but not with 4.2.5.

Solution:

The issue arises due to a dependency conflict between Play Java JPA and Hibernate 4.3. Play Java JPA depends on the JPA 2.0 specification, while Hibernate 4.3 utilizes the newer JPA 2.1 specification.

Fix:

Modify the build.sbt file by adding the following dependency:

libraryDependencies ++= Seq(
javaJdbc,
javaJpa.exclude("org.hibernate.javax.persistence", "hibernate-jpa-2.0-api"),
"org.hibernate" % "hibernate-entitymanager" % "4.3.0.Final"
)

This step excludes the JPA 2.0 dependency and ensures that only JPA 2.1 is used. This solution is applicable to Play 2.2.x versions.

Note:

The issue may require different modifications for earlier versions of Play.

The above is the detailed content of Why Does Upgrading Hibernate from 4.2.5 to 4.3.0 Cause a NoSuchMethodError for javax.persistence.Table.indexes()?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn