user655577
user655577

Reputation: 231

JPA + Hibernate getting NoSuchFieldError

I'm getting strange java.lang.NoSuchFieldError: NONE runtime error which trying to use JPA with Oracle DB. I'm using Maven build. Here are the key files. I'm guessing that there's an issue with some JAR.

pox.xml

    <dependency>
              <groupId>javax.persistence</groupId>
              <artifactId>persistence-api</artifactId>
              <version>1.0.2</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>3.5.6-Final</version>
    </dependency>

persistence.xml

   <persistence-unit name="ifp-test" transaction-type="RESOURCE_LOCAL">
      <provider>org.hibernate.ejb.HibernatePersistence</provider>
      <properties>
         <property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver"/>
         <property name="javax.persistence.jdbc.user" value="something"/>
         <property name="javax.persistence.jdbc.password" value="something"/>
          <property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin://@something_here"/>
         <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
         <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
      </properties>
   </persistence-unit>
</persistence>

Java Code

    List arr_cust = entityManagerFactory.createEntityManager().createNativeQuery(sql_query).getResultList();

Can someone please point in the right direction ?

Upvotes: 0

Views: 2357

Answers (1)

user655577
user655577

Reputation: 231

I found a solution. The issue was in pom.xml. Here's the correct pom.xml.

    <dependency>
        <groupId>org.hibernate.javax.persistence</groupId>
        <artifactId>hibernate-jpa-2.0-api</artifactId>
        <version>1.0.0.Final</version>
    </dependency>
    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <version>3.5.6-Final</version>
</dependency>

Upvotes: 1

Related Questions