<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0062)http://www.cnblogs.com/renrenqq/archive/2006/08/16/478198.html -->
<HTML><HEAD id=Head><TITLE>NHibernate的关联映射(one-to-one,one-to-many,many-to-many)以及cascade分析 - DDLLY命名空间 - 博客园</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<META id=metaKeywords
content=NHibernate的关联映射(one-to-one,one-to-many,many-to-many)以及cascade分析
name=keywords><LINK id=MainCss
href="NHibernate的关联映射(one-to-one,one-to-many,many-to-many)以及cascade分析 - DDLLY命名空间 - 博客园_files/style.css"
type=text/css rel=stylesheet><LINK id=SecondaryCss
href="NHibernate的关联映射(one-to-one,one-to-many,many-to-many)以及cascade分析 - DDLLY命名空间 - 博客园_files/customcss.css"
type=text/css rel=stylesheet><LINK id=RSSLink title=RSS
href="http://www.cnblogs.com/renrenqq/rss.aspx" type=application/rss+xml
rel=alternate>
<META content="MSHTML 6.00.3790.3959" name=GENERATOR></HEAD>
<BODY>
<FORM id=Form1 name=Form1 onsubmit="javascript:return WebForm_OnSubmit();"
action=478198.html method=post>
<DIV><INPUT id=__EVENTTARGET type=hidden name=__EVENTTARGET> <INPUT
id=__EVENTARGUMENT type=hidden name=__EVENTARGUMENT> <INPUT
id=" __VIEWSTATE" type=hidden name=__VIEWSTATE> </DIV>
<SCRIPT type=text/javascript>
<!--
var theForm = document.forms['Form1'];
if (!theForm) {
theForm = document.Form1;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
// -->
</SCRIPT>
<SCRIPT
src="NHibernate的关联映射(one-to-one,one-to-many,many-to-many)以及cascade分析 - DDLLY命名空间 - 博客园_files/WebResource.axd"
type=text/javascript></SCRIPT>
<SCRIPT language=JavaScript>
function ctlent(evt,id)
{
if(evt.ctrlKey && evt.keyCode == 13)
{
try
{
TempSave(id);
}
catch(ex)
{
}
finally
{
__doPostBack('AjaxHolder$PostComment$btnSubmit','')
}
}
}</SCRIPT>
<SCRIPT language=JavaScript>function SetReplyAuhor(author){document.getElementById('AjaxHolder_PostComment_tbComment').value+="@"+author+"\n";document.getElementById('AjaxHolder_PostComment_tbComment').focus();return false}</SCRIPT>
<SCRIPT
src="NHibernate的关联映射(one-to-one,one-to-many,many-to-many)以及cascade分析 - DDLLY命名空间 - 博客园_files/ScriptResource.axd"
type=text/javascript></SCRIPT>
<SCRIPT
src="E:\hibernate\NHibernate的关联映射(one-to-one,one-to-many,many-to-many)以及cascade分析 - DDLLY命名空间 - 博客园_files\ScriptResource(1).axd"
type=text/javascript></SCRIPT>
<SCRIPT
src="E:\hibernate\NHibernate的关联映射(one-to-one,one-to-many,many-to-many)以及cascade分析 - DDLLY命名空间 - 博客园_files\ScriptResource(2).axd"
type=text/javascript></SCRIPT>
<SCRIPT
src="NHibernate的关联映射(one-to-one,one-to-many,many-to-many)以及cascade分析 - DDLLY命名空间 - 博客园_files/js"
type=text/javascript></SCRIPT>
<SCRIPT type=text/javascript>
<!--
function WebForm_OnSubmit() {
if (typeof(ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) return false;
return true;
}
// -->
</SCRIPT>
<!--done-->
<DIV id=header><!--done-->
<DIV class=header>
<DIV class=headerText><A class=headermaintitle id=Header1_HeaderTitle
href="http://www.cnblogs.com/renrenqq/">DDLLY命名空间</A><BR>
<TABLE width="100%" border=0>
<TBODY>
<TR>
<TD> DDLLY命名空间有两个类DDL和LLY</TD>
<TD rowSpan=3>
<SCRIPT type=text/javascript><!--
google_ad_client = "pub-3076718755126851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
google_ad_channel ="";
//--></SCRIPT>
<SCRIPT
src="NHibernate的关联映射(one-to-one,one-to-many,many-to-many)以及cascade分析 - DDLLY命名空间 - 博客园_files/show_ads.js"
type=text/javascript>
</SCRIPT>
</TD></TR>
<TR>
<TD> <A
href="http://renrenqq.cnblogs.com/archive/2005/11/24/283757.html">NHibernate翻译文档提供下载(chm格式和html格式)</A></TD></TR>
<TR>
<TD> <A
href="http://www.cnblogs.com/renrenqq/archive/2006/08/03/466636.html">有关NHibernate的问题请在此提出
</A></TD></TR>
<TR>
<TD> <A
href="http://www.cnblogs.com/renrenqq/archive/2006/08/14/476350.html">欢迎加入O/R
Mapping团队</A></TD></TR></TBODY></TABLE></DIV></DIV></DIV>
<DIV id=mytopmenu>
<DIV id=mylinks><!--done--><A class=menu id=MyLinks1_HomeLink
href="http://www.cnblogs.com/">博客园</A> <A class=menu
id=MyLinks1_MyHomeLink href="http://renrenqq.cnblogs.com/">首页</A> <A
class=menu id=MyLinks1_ContactLink
href="http://www.cnblogs.com/renrenqq/contact.aspx?id=1">联系</A> <A
class=menu id=MyLinks1_Syndication
href="http://www.cnblogs.com/renrenqq/rss">订阅</A><A id=MyLinks1_XMLLink
href="http://www.cnblogs.com/renrenqq/rss"><IMG
style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px"
alt=订阅
src="NHibernate的关联映射(one-to-one,one-to-many,many-to-many)以及cascade分析 - DDLLY命名空间 - 博客园_files/xml.gif"></A>
<A class=menu id=MyLinks1_Admin
href="http://www.cnblogs.com/renrenqq/admin/EditPosts.aspx">管理</A> </DIV>
<DIV id=mystats><!--done-->随笔-81 评论-826 文章-0 trackbacks-46
</DIV></DIV>
<DIV id=centercontent>
<SCRIPT type=text/javascript>
//<![CDATA[
Sys.WebForms.PageRequestManager._initialize('AjaxHolder$scriptmanager1', document.getElementById('Form1'));
Sys.WebForms.PageRequestManager.getInstance()._updateControls(['tAjaxHolder$UpdatePanel1'], [], [], 90);
//]]>
</SCRIPT>
<!--done-->
<DIV class=post>
<DIV class=postTitle><A class=postTitle2 id=AjaxHolder_ctl01_TitleUrl
href="http://www.cnblogs.com/renrenqq/archive/2006/08/16/478198.html">NHibernate的关联映射(one-to-one,one-to-many,many-to-many)以及cascade分析</A>
</DIV>
<P class=h1>一、典型设置</P>
<P>cascade:(默认为none)级联。指明哪些操作会从对象级联到关联的对象。</P>
<P>inverse: (默认为false)
标记这个集合作为双向关联关系中的方向一端。在双向关联时才需要设置。在设为false的一端对cascade进行维护。处于性能的考虑,一般在数据少的一端或者被依赖端设置inverse="true",而让数据多的一段维护cascade。</P>
<P class=h2>1.one-to-one</P>
<P class=h3>1.1 数据库表结构</P>
<P>其中T_Person为主表,T_Employee为子表。T_Employee的PersonId参照T_Peson的PersonId。</P>
<P><IMG height=87 alt=""
src="NHibernate的关联映射(one-to-one,one-to-many,many-to-many)以及cascade分析 - DDLLY命名空间 - 博客园_files/o_OneToOne.jpg"
width=499 border=0></P>
<P class=h3>1.2 示例映射类文件<BR><BR></P>
<P class=h3></P>
<P class=h3></P>
<DIV
style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG
id=Codehighlighter1_0_47_Open_Image
onclick="this.style.display='none'; Codehighlighter1_0_47_Open_Text.style.display='none'; Codehighlighter1_0_47_Closed_Image.style.display='inline'; Codehighl