1

this is my pom.xml:

  <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-entitymanager</artifactId>
      <version>3.5.1-Final</version>
  </dependency>

  <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-core</artifactId>
      <version>3.6.10.Final</version>
  </dependency>

When I have these 2 dependencies, I can successfully run my Hello World example. ( Which uses a persistence.xml and a class which is mapped to a table in my DB with @Entity annotation. However when I change my hibernate-core to:

<dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-core</artifactId>
      <version>4.2.1.Final</version>
  </dependency>

I get :

Exception in thread "main" java.lang.IllegalAccessError: tried to access method org.hibernate.cfg.Configuration.(Lorg/hibernate/cfg/SettingsFactory;)V from class org.hibernate.ejb.Ejb3Configuration

So how can I use hibernate core 4.2.1 final as a JPA implementation? I guess there is no version 4 for hibernate-entitymanager ?

2 Answers 2

2

just change hibernate-entitymanager to the same version

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <version>4.2.1.Final</version>
</dependency>
Sign up to request clarification or add additional context in comments.

Comments

2

This setup works for me. You need the same or similar release/version numbers for both components, because they are too different if you use 4.x.x and 3.x.x together.

<dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>4.1.1.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>4.1.1.Final</version>
    </dependency>

A common way to deal with (Hibernate or other) version numbers is to specify the version once in a property, like this

<properties>
    <hibernate.version>4.1.1.Final</hibernate.version>
</properties>

And then refer to that property in the dependency declaration..

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>${hibernate.version}</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>${hibernate.version}</version>
    </dependency>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.