【问题标题】:Hibernate jars compatibility issuesHibernate jars 兼容性问题
【发布时间】:2013-10-03 10:01:12
【问题描述】:

我是hibernate的新手。谁能帮我找出我应该添加的所有罐子(如搜索、注释、JBoss 等)我使用的是休眠 3.5.1 FINAL。 这是当前的 pom.xml 和 hibernate.cfg.xml ,

但我发现版本存在一些兼容性问题。

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>

【问题讨论】:

  • but i found there are some compatibility issues in versions. pom.xml,这些是什么?
  • Error:"IncompatibleClassChangeError: class org.hibernate.cfg.ExtendedMappings has interface org.hibernate.cfg.Mappings as super class" 经过一番搜索后我发现了这个stackoverflow.com/questions/8663429/…
  • 我也收到“未启用休眠搜索”
  • 您正在启动一个项目,并使用过时版本的 Hibernate。为什么?为什么不使用最新版本,从而避免从 3.5.1 开始修复的所有错误,超过 3 年?
  • @Ankita 如果可能的话,按照 JB 的建议转移最新版本,或者按照表格的建议进行组合。

标签: java hibernate maven hibernate-search hibernate-annotations


【解决方案1】:

查看 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) 的 POM,您可以看到在 4.1.3.Final 版本中需要 Hibernate ORM。这就是我要开始的(绝对没有旧版本)。

另外,为什么要明确指定 Hibernate ORM、Annotations 等的版本。如果您只是指定您希望的 Hibernate Search 版本,那么您将自动获取所有其他 Hibernate 依赖项作为其正确版本中的传递依赖项。

然后,最后但并非最不重要的一点是,为什么要搜索 4.1.3?还有一个 4.3.0.Final 可用。

【讨论】:

  • 现在,我已经切换回旧版本.. 但是谢谢你,我会试试上面的:)
猜你喜欢
  • 2012-07-05
  • 1970-01-01
  • 2016-03-07
  • 1970-01-01
  • 1970-01-01
  • 2016-08-28
  • 2014-02-12
  • 2011-10-04
相关资源
最近更新 更多