扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:ghost 来源:CSDN 2007年9月24日
关键字: ghost NHibernate 集合 组合依赖
public class CompositeUser { int _uid; UserName _name; public int Uid { get { return _uid; } set { _uid = value; } } public UserName Name { get { return _name; } set { _name = value; } } }
public class UserName { private string _firstName; private string _lastName; CompositeUser _user; public string FirstName { get { return _firstName; } set { _firstName=value; } } public string LastName { get { return _lastName; } set { _lastName = value; } } public CompositeUser User { get { return _user; } set { _user = value; } } }
<?xml version="1.0" encoding="utf-8" ?><hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> <class name="NhibernateSample1.CompositeUser,NhibernateSample1" table="CompositeUser" lazy="false"> <id name="Uid" column="Uid" unsaved-value="0"> <generator class="native" /> </id> <component name="Name" class="NhibernateSample1.UserName,NhibernateSample1"> <parent name="User"></parent> <property name="FirstName" column="FirstName"></property> <property name="LastName" column="LastName"></property> </component> </class></hibernate-mapping>
public class CompositeUser { int _uid; UserName _name; ISet _userNames = new HashedSet(); DateTime _birthDay = DateTime.Now; public int Uid { get { return _uid; } set { _uid = value; } } public ISet UserNames { get { return _userNames; } set { _userNames = value; } } public DateTime BirthDay { get { return _birthDay; } set { _birthDay = value; } } }
public class UserName{ private string _firstName; private string _lastName; CompositeUser _user; public string FirstName { get { return _firstName; } set { _firstName = value; } } public string LastName { get { return _lastName; } set { _lastName = value; } } public CompositeUser User { get { return _user; } set { _user = value; } }}
<?xml version="1.0" encoding="utf-8" ?><hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> <class name="NhibernateSample1.CompositeUser,NhibernateSample1" table="CompositeUser" lazy="false"> <id name="Uid" column="Uid" unsaved-value="0"> <generator class="native" /> </id> <set name="UserNames" table="UserNames" lazy="true"> <key column="Uid"/> <composite-element class="NhibernateSample1.UserName,NhibernateSample1"> <property name="FirstName" column="FirstName"></property> <property name="LastName" column="LastName"></property> </composite-element > </set> <property name="BirthDay" type="DateTime"></property> </class></hibernate-mapping>
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1741145
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者