现在大量的搜索引擎困惑和沮丧。使用hibernate 4 hbm.xml和xsd
我正在将应用程序从Hibernate 3升级到4.这很适合使用dtd 3.0,但现在需要使用4.0 xsd,并且这是每一件事情都是基于顶点的地方!
该应用程序使用hbm.xml文件来配置每个实体,没有任何注释任何地方。
找到一个hbm文件的例子是非常有用的,但即使是使用3.0 dtd的hibernate 4教程!
我使用以下
<hibernate-mapping
xmlns="http://www.hibernate.org/xsd/hibernate-mapping"
xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-mapping hibernate-mapping-4.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
package="org.hibernate.metamodel.binding">
使用此我得到错误的一长串的根本原因是
Caused by: org.xml.sax.SAXParseException; lineNumber: 6; columnNumber: 51; cvc-elt.1: Cannot find the declaration of element 'hibernate-mapping'.
我的多个谷歌页面的阅读建议,我还需要一个DOCTYPE这是混乱,我想我只是误解,当我添加一个doctype Eclipse抱怨hibernate-mapping元素的定义。忽略这个错误(只是柜面问题与Eclipse配置)获得相同的运行时错误:
Attribute "xmlns" must be declared for element type "hibernate-mapping"
我一直无法找到一个教程或使用Hibernate 4 XSD一个hbm.xml文件中的一个例子。
任何人都可以请我摆脱我的苦难吗?
有什么遗漏或我不理解。 – user2120275