最近一段时间在学习NHibernate,暂时先不管它NHiberNate是什么东西,先把我在学习中遇到的几个问题记载以来,如果有人遇到同样的问题,也好少走弯路。
我的NHibernate版本为:0.9.10.0
1:建立了一个配置文件,编译时遇到了这样的问题“命名空间“urn:nhibernate-mapping-2.0”中的“class”。 的子元素 命名空间“urn:nhibernate-mapping-2.0”中的“property”。 无效。应为可能元素的列表: ‘urn:nhibernate-mapping-2.0:meta urn:nhibernate-mapping-2.0:jcs-cache urn:nhibernate-mapping-2.0:cache urn:nhibernate-mapping-2.0:id urn:nhibernate-mapping-2.0:composite-id‘。”。

配置文件名称:RecorderDT.hbm.xml
内容:
<?xml version="1.0" encoding="utf-8" ?>
 <hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" >
  <class name="Data.RectypeDT, Data" table="RecType">
   <property  name="RecTypeId" type="Int32" column="RecTypeId" insert="false">
    <generator class="identity"/>
   </property >
   <property name="RecTypeName" type="String(10)" column="RecTypeName" />
   </class>
</hibernate-mapping>

错误原因:
在property元素的子元素之前,必须是 <id> 或 <composite-id>子元素。
所以,修改后的配置文件内容:
<?xml version="1.0" encoding="utf-8" ?>
 <hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" >
  <class name="Data.RectypeDT, Data" table="RecType">
   <id  name="RecTypeId" type="Int32" column="RecTypeId" insert="false">
    <generator class="identity"/>
   </id>
   <property name="RecTypeName" type="String(10)" column="RecTypeName" />
   </class>
</hibernate-mapping>

相关文章:

  • 2021-08-01
  • 2021-07-09
  • 2021-06-09
  • 2021-05-31
  • 2021-05-30
  • 2021-07-21
  • 2022-12-23
猜你喜欢
  • 2021-05-25
  • 2022-02-26
  • 2021-07-08
  • 2021-09-19
  • 2022-12-23
  • 2021-12-12
  • 2022-01-25
相关资源
相似解决方案