0

我正在尝试使用hibernate 3进行练习。我有这个错误。

Exception in thread "main" org.hibernate.MappingException: Error reading resource: test/Reservation.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:452)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1263)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1235)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1217)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1184)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1112)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1098)
at HibTestMain.main(HibTestMain.java:16)
Caused by: org.hibernate.MappingException: invalid mapping
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:399)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:449)
... 7 more
Caused by: org.xml.sax.SAXParseException: The content of element type "version"     must     match "(meta)*".
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:465)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:398)
... 8 more

这是我的 hbm 文件。

<hibernate-mapping package="org.azureworlds.dao">
 <class name="Reservation" table="reservation">
  <id name="id" type="integer">
   <column name="ID"/>
   <generator class="native"/>
  </id>
  <version  name="version" type="integer">
            <column name="VERSION" />
  </version>
  <property generated="never" lazy="false" name="creationTime" type="timestamp">
   <column length="0" name="CREATION_TIME" not-null="true"/>
  </property>
 </class>
</hibernate-mapping>

我究竟做错了什么。似乎问题出在版本标签上。我尝试了不同的东西,但在静脉中。

bean 和 hbm 文件由 MyEclipse Persistence Tools 生成

如果需要,将提供更多信息。提前致谢

4

1 回答 1

0

改变

<version  name="version" type="integer">
        <column name="VERSION" />

<version column="VERSION" name="version" type="integer" />
于 2013-03-22T12:27:12.627 回答