/// <summary> /// 会员 /// </summary> public class User { [DisplayName("姓名:")] public virtual String Name { get; set; } [DisplayName("职位:")] public virtual Post Post { get; set; } }
<?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="UU.Models" namespace="UU.Models"> <class name="User" table="U_User" > <id name="ID" type="guid"> <generator class="assigned" /> </id> <property name="Name"/> <many-to-one name="Post" column="PostID" not-null="false" class="UU.Models.Post,UU" foreign-key="FK_User_Post" / </class> </hibernate-mapping>
当然在添加用户的时候职位不选,它就会出错。错误:could not execute batch command.[SQL: SQL not available]
还有我跟踪sql语句的时候发现它会有INSERT后进行UPDATE
not-null="false" cascade="none" lazy="false" insert="false" update="false"