逆水行船

别人的天堂,是我的异乡;无端的繁华,倍添我的惆怅

 

学习NHibernate的时候遇到的几个问题

最近一段时间在学习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>

posted on 2007-02-01 23:06  荣-  阅读(1086)  评论(2编辑  收藏  举报

导航