1

I am a newbie in hibernate. Can anyone help me finding out what all jars should I add (like search, annotaions , JBoss etc.) I am using hibernate 3.5.1 FINAL. Here is the current pom.xml and hibernate.cfg.xml ,

but i found there are some compatibility issues in versions.

Error:"IncompatibleClassChangeError: class org.hibernate.cfg.ExtendedMappings  
                      has interface org.hibernate.cfg.Mappings as super class"

pom.xml

`
    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>3.5.1-Final</version>
  </dependency>
  <dependency>
         <groupId>org.hibernate</groupId>
         <artifactId>hibernate-entitymanager</artifactId>
         <version>3.5.1-Final</version>
        </dependency>
  <dependency>
    <groupId>org.ancoron.postgresql</groupId>
    <artifactId>org.postgresql</artifactId>
    <version>9.1.901.jdbc4.1-rc9</version>
  </dependency>
    <dependency>
      <groupId>commons-collections</groupId>
      <artifactId>commons-collections</artifactId>
      <version>3.2.1</version>
    </dependency>
      <dependency>
        <groupId>javax.transaction</groupId>
        <artifactId>jta</artifactId>
        <version>1.1</version>
    </dependency>
   <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-annotations</artifactId>
      <version>3.4.0.GA</version>
    </dependency>
    <dependency>
    <groupId>org.hibernate.common</groupId>
    <artifactId>hibernate-commons-annotations</artifactId>
    <version>4.0.1.Final</version>
</dependency>
<dependency>
    <groupId>org.jboss.logging</groupId>
    <artifactId>jboss-logging</artifactId>
    <version>3.1.0.CR1</version>
</dependency>
<dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate-search</artifactId>
   <version>4.1.1.Final</version>
</dependency>
<dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate-search-infinispan</artifactId>
   <version>4.1.1.Final</version>
</dependency>
 </dependencies>
 <repositories>
      <repository>
    <id>JBoss repository</id>
    <url>http://repository.jboss.org/nexus/content/groups/public/</url>
      </repository>
    </repositories>`

hibernate.cfg.xml

  <?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
   <session-factory>
   <property name="hibernate.dialect">
      org.hibernate.dialect.PostgreSQLDialect
   </property>
   <property name="hibernate.connection.driver_class">
   org.postgresql.Driver
   </property>


   <property name="hibernate.connection.url">
      jdbc:postgresql://localhost:5432/
   </property>
   <property name="hibernate.default_schema">alerts</property>
   <property name="hibernate.connection.username">
      postgres
   </property>
   <property name="hibernate.connection.password">
      password
   </property>

    <property name="hibernate.search.default.directory_provider" >
    org.hibernate.search.store.FSDirectoryProvider
    </property>            
    <property name="hibernate.search.default.indexBase">
    C:\temp\indexes
    </property>          

    <property name="hibernate.ejb.event.post-insert" >
    "org.hibernate.search.event.FullTextIndexEventListener
    </property>
    <property name="hibernate.ejb.event.post-update" >
    org.hibernate.search.event.FullTextIndexEventListener
    </property>
    <property name="hibernate.ejb.event.post-delete" >
    org.hibernate.search.event.FullTextIndexEventListener"
    </property>

<mapping class="something.classname" />
   </session-factory>
</hibernate-configuration>
Suresh Atta
  • 120,458
  • 37
  • 198
  • 307
Ankita
  • 197
  • 1
  • 11
  • `but i found there are some compatibility issues in versions. pom.xml`, What are those? – Suresh Atta Oct 03 '13 at 10:03
  • Error:"IncompatibleClassChangeError: class org.hibernate.cfg.ExtendedMappings has interface org.hibernate.cfg.Mappings as super class" after searching a bit i found this http://stackoverflow.com/questions/8663429/java-lang-incompatibleclasschangeerror – Ankita Oct 03 '13 at 10:11
  • Also i m getting "Hibernate search not enabled" – Ankita Oct 03 '13 at 10:14
  • You're starting a project, and using an obsolete version of Hibernate. Why? Why don't you use the latest version and thus avoid all the bugs that have been fixed since 3.5.1, more than 3 years ago? – JB Nizet Oct 03 '13 at 10:15
  • @Ankita If possible shift latest version's as JB suggested or else make the combo as the table suggested. – Suresh Atta Oct 03 '13 at 10:19
  • what is safest latest version that i can use? Also , should i remove other jars like annotations ,search etc. Is hibernate 4 bonded with all these? – Ankita Oct 03 '13 at 10:26

1 Answers1

1

Looking at the POM for Hibernate Search 4.1.1.Final (https://repository.jboss.org/nexus/content/repositories/public/org/hibernate/hibernate-search-parent/4.1.1.Final/hibernate-search-parent-4.1.1.Final.pom) you can see that is requires Hibernate ORM in version 4.1.3.Final. That's what I would start with (definitely no older version).

Also, why do you specify the versions of Hibernate ORM, Annotations etc explicitly. If you just specify the Hibernate Search version you want you get all other Hibernate dependencies automatically as transitive dependencies in their right version.

And then, last but not least, why Search 4.1.3? There is a 4.3.0.Final available as well.

Hardy
  • 18,659
  • 3
  • 49
  • 65
  • For now, i have switched back to older version.. but thank you, i will try with the above :) – Ankita Oct 04 '13 at 11:34