- 数据库对象的配置文件×××.hbm.xml,一定要将生成操作设置成嵌入的资源
- ×××.hbm.xml中的内容
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="NhibernateStudy.PortalUser(类名),NhibernateStudy(程序集名称)" table="PortalUser" lazy="false">
<id name="Id" column="Id" unsaved-value="0">
<generator class="assigned" /><!--生成Id的类名一定要小写,有哪些类可以选择可以在Nhibernate的源代码中的Id目录下找到-->
</id>
<property name="UserName" column="UserName" type="string" length="64" not-null="true" unique="true"></property>
<property name="Password" column="Password" type="string" length="64" not-null="true"></property>
</class>
</hibernate-mapping>
转载于:https://www.cnblogs.com/Aldebaran/archive/2008/07/24/1250389.html