野飞10中的Hibernate 4.3支持

4

问题描述:

在Wildfly 10中是否支持Hibernate 4?我在互联网上找到了版本5的支持,但是关于版本4没有任何信息。

当在Wildfly 10上部署代码时,遇到以下异常:

无效内容从元素'create'开始发现。期望其中之一'{"http://www.hibernate.org/xsd/orm/hbm":drop}'。

如何解决此异常?


请问您能否发布XML文件吗? - Alexandre Cartapanis
首先,这似乎与您的Hibernate配置XML中的配置问题有关-请参见此处,例如:https://dev59.com/q2Qn5IYBdhLWcg3wAjIY - cslotty
1个回答

5
在Wildfly 10中,Hibernate版本升级到了5.x。因此,默认持久性提供程序是Hibernate 5.x。
然而,Wildfly 10并没有完全放弃对Hibernate 4的支持。有两种方法可以使其工作。
1) 每次部署打包
将所有Hibernate 4.x jar文件打包到您的部署文件中,并在persistence.xml中将"jboss.as.jpa.providerModule"属性设置为"application"。
参考:https://docs.jboss.org/author/display/WFLY10/JPA+Reference+Guide#JPAReferenceGuide-PackagingtheHibernateJPApersistenceproviderwithyourapplication 2) Wildfly全局模块(适用于所有部署)
将Hibernate 4.3 jar文件添加到Wildfly Hibernate模块中,并在persistence.xml中将"jboss.as.jpa.providerModule"属性设置为"4.x"(根据Hibernate的module.xml指定的特定版本)。
参考:https://docs.jboss.org/author/display/WFLY9/JPA+Reference+Guide#JPAReferenceGuide-SharingtheHibernate3.5orgreaterJPApersistenceproviderbetweenmultipleapplications 顺便说一下,Wildfly 10完全删除了对Hibernate 3.x的支持。

Sriram,"ernate 3.x support is completely removed in wildfly 10"是什么意思?如果我将Hibernate 3 JAR包打包到我的应用程序中,并在所有模块中排除Hibernate 5,会发生什么? - inor
jboss.as.jpa.providerModule 的值设置为 < 4 将不会被 Wildfly 所识别。因此,您不能使用它。 - Sri

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接