⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 performance.html

📁 hibernate的一点学习资料!
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<html><head>      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">   <title>Chapter&nbsp;12.&nbsp;&#24615;&#33021;&#25552;&#21319;&#65288;Improving Performance&#65289;</title><link rel="stylesheet" href="../styles/html.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.60.1"><link rel="home" href="index.html" title="HIBERNATE - &#31526;&#21512;Java&#20064;&#24815;&#30340;&#20851;&#31995;&#25968;&#25454;&#24211;&#25345;&#20037;&#21270;"><link rel="up" href="index.html" title="HIBERNATE - &#31526;&#21512;Java&#20064;&#24815;&#30340;&#20851;&#31995;&#25968;&#25454;&#24211;&#25345;&#20037;&#21270;"><link rel="previous" href="worked-example.html" title="Chapter&nbsp;11.&nbsp;&#23454;&#20363;(A Worked Example)"><link rel="next" href="collection-performance.html" title="Chapter&nbsp;13.&nbsp;&#29702;&#35299;&#38598;&#21512;&#31867;&#30340;&#24615;&#33021;&#65288;Understanding Collection Performance&#65289;"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter&nbsp;12.&nbsp;&#24615;&#33021;&#25552;&#21319;&#65288;Improving Performance&#65289;</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="worked-example.html">Prev</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="collection-performance.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="performance"></a>Chapter&nbsp;12.&nbsp;&#24615;&#33021;&#25552;&#21319;&#65288;Improving Performance&#65289;</h2></div></div><div></div></div><p>        &#25105;&#20204;&#24050;&#32463;&#20026;&#24744;&#23637;&#31034;&#20102;&#22914;&#20309;&#22312;&#23545;&#38598;&#21512;&#25345;&#20037;&#21270;&#26102;&#20351;&#29992;&#24310;&#36831;&#35013;&#36733;&#65288;lazy initialization&#65289;&#12290;&#23545;&#20110;&#36890;&#24120;&#30340;&#23545;&#35937;&#24341;&#29992;&#65292;&#20351;&#29992;CGLIB&#20195;&#29702;&#21487;&#20197;&#36798;&#21040;&#31867;&#20284;&#30340;&#25928;&#26524;&#12290;&#25105;&#20204;&#20063;&#25552;&#21040;&#36807;Hibernate&#22312;<tt class="literal">Session</tt>&#32423;&#21035;&#32531;&#23384;&#25345;&#20037;&#21270;&#23545;&#35937;&#12290;&#36824;&#26377;&#26356;&#22810;&#20808;&#36827;&#30340;&#32531;&#23384;&#31574;&#30053;&#65292;&#20320;&#21487;&#20197;&#20026;&#27599;&#19968;&#20010;&#31867;&#21333;&#29420;&#37197;&#32622;&#12290;    </p><p>        &#36825;&#19968;&#31456;&#37324;&#65292;&#25105;&#20204;&#26469;&#25945;&#20320;&#22914;&#20309;&#20351;&#29992;&#36825;&#20123;&#29305;&#24615;&#65292;&#22312;&#24517;&#35201;&#30340;&#26102;&#20505;&#24471;&#21040;&#39640;&#24471;&#22810;&#30340;&#24615;&#33021;&#12290;    </p><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="performance-s4"></a>12.1.&nbsp;&#29992;&#20110;&#24310;&#36831;&#35013;&#36733;&#30340;&#20195;&#29702;</h2></div></div><div></div></div><p>            Hibernate&#20351;&#29992;&#21160;&#24577;&#23383;&#33410;&#30721;&#22686;&#24378;&#25216;&#26415;&#26469;&#23454;&#29616;&#25345;&#20037;&#21270;&#23545;&#35937;&#30340;&#24310;&#36831;&#35013;&#36733;&#20195;&#29702;&#65288;&#20351;&#29992;&#20248;&#31168;&#30340;CGLIB&#24211;&#65289;&#12290;        </p><p>        	&#26144;&#23556;&#25991;&#20214;&#20026;&#27599;&#19968;&#20010;&#31867;&#22768;&#26126;&#19968;&#20010;&#31867;&#25110;&#32773;&#25509;&#21475;&#20316;&#20026;&#20195;&#29702;&#25509;&#21475;&#12290;&#24314;&#35758;&#20351;&#29992;&#36825;&#20010;&#31867;&#33258;&#36523;&#65306;        </p><pre class="programlisting">&lt;class name="eg.Order" proxy="eg.Order"&gt;</pre><p>            &#36816;&#34892;&#26102;&#30340;&#20195;&#29702;&#24212;&#35813;&#26159;<tt class="literal">Order</tt>&#30340;&#23376;&#31867;&#12290;&#27880;&#24847;&#34987;&#20195;&#29702;&#30340;&#31867;&#24517;&#39035;&#23454;&#29616;&#19968;&#20010;&#40664;&#35748;&#30340;&#26500;&#36896;&#22120;&#65292;&#24182;&#19988;&#33267;&#23569;&#22312;&#21253;&#20869;&#21487;&#35265;&#12290;        </p><p>            &#22312;&#25193;&#23637;&#36825;&#31181;&#26041;&#27861;&#26469;&#23545;&#24212;&#22810;&#24418;&#30340;&#31867;&#26102;&#65292;&#35201;&#27880;&#24847;&#19968;&#20123;&#32454;&#33410;,&#27604;&#22914;&#65306;        </p><pre class="programlisting">&lt;class name="eg.Cat" proxy="eg.Cat"&gt;    ......    &lt;subclass name="eg.DomesticCat" proxy="eg.DomesticCat"&gt;        .....    &lt;/subclass&gt;&lt;/class&gt;</pre><p>            &#39318;&#20808;&#65292;<tt class="literal">Cat</tt>&#27704;&#36828;&#19981;&#33021;&#34987;&#24378;&#21046;&#36716;&#25442;&#20026;<tt class="literal">DomesticCat</tt>,&#21363;&#20351;&#23454;&#38469;&#19978;&#35813;&#23454;&#20363;&#23601;&#26159;&#19968;&#20010;<tt class="literal">DomesticCat</tt>&#23454;&#20363;&#12290;        </p><pre class="programlisting">Cat cat = (Cat) session.load(Cat.class, id);  // instantiate a proxy (does not hit the db)if ( cat.isDomesticCat() ) {                  // hit the db to initialize the proxy    DomesticCat dc = (DomesticCat) cat;       // Error!    ....}</pre><p>            &#20854;&#27425;&#65292;&#20195;&#29702;&#30340;<tt class="literal">==</tt>&#21487;&#33021;&#19981;&#20877;&#25104;&#31435;&#12290;        </p><pre class="programlisting">Cat cat = (Cat) session.load(Cat.class, id);            // instantiate a Cat proxyDomesticCat dc =     (DomesticCat) session.load(DomesticCat.class, id);  // required new DomesticCat proxy!System.out.println(cat==dc);                            // false</pre><p>            &#34429;&#28982;&#22914;&#27492;&#65292;&#36825;&#31181;&#24773;&#20917;&#24182;&#19981;&#20687;&#30475;&#19978;&#21435;&#24471;&#37027;&#20040;&#31967;&#12290;&#34429;&#28982;&#25105;&#20204;&#29616;&#22312;&#26377;&#20004;&#20010;&#19981;&#21516;&#30340;&#24341;&#29992;&#26469;&#25351;&#21521;&#19981;&#21516;&#30340;&#20195;&#29702;&#23545;&#35937;&#65292;&#23454;&#38469;&#19978;&#24213;&#23618;&#30340;&#23454;&#20363;&#24212;&#35813;&#26159;&#21516;&#19968;&#20010;&#23545;&#35937;&#65306;        </p><pre class="programlisting">cat.setWeight(11.0);  // hit the db to initialize the proxySystem.out.println( dc.getWeight() );  // 11.0</pre><p>            &#31532;&#19977;&#65292;&#20320;&#19981;&#33021;&#23545;<tt class="literal">final</tt>&#30340;&#31867;&#25110;&#32773;&#20855;&#26377;<tt class="literal">final</tt>&#26041;&#27861;&#30340;&#31867;&#20351;&#29992;CGLIB&#20195;&#29702;&#12290;        </p><p>            &#26368;&#21518;,&#20551;&#22914;&#20320;&#30340;&#25345;&#20037;&#21270;&#23545;&#35937;&#22312;&#23454;&#20363;&#21270;&#30340;&#26102;&#20505;&#38656;&#35201;&#26576;&#20123;&#36164;&#28304;&#65288;&#27604;&#22914;&#65292;&#22312;&#23454;&#20363;&#21270;&#26041;&#27861;&#25110;&#32773;&#40664;&#35748;&#26500;&#36896;&#26041;&#27861;&#20013;&#65289;&#65292;&#36825;&#20123;&#36164;&#28304;&#20063;&#20250;&#34987;&#20195;&#29702;&#38656;&#35201;&#12290;&#20195;&#29702;&#31867;&#23454;&#38469;&#19978;&#26159;&#25345;&#20037;&#21270;&#31867;&#30340;&#23376;&#31867;&#12290;        </p><p>            &#36825;&#20123;&#38382;&#39064;&#37117;&#26469;&#28304;&#20110;Java&#30340;&#21333;&#26681;&#32487;&#25215;&#27169;&#22411;&#30340;&#22825;&#29983;&#38480;&#21046;&#12290;&#22914;&#26524;&#20320;&#24076;&#26395;&#36991;&#20813;&#36825;&#20123;&#38382;&#39064;&#65292;&#20320;&#30340;&#27599;&#20010;&#25345;&#20037;&#21270;&#31867;&#24517;&#39035;&#25277;&#35937;&#20986;&#19968;&#20010;&#25509;&#21475;&#65292;&#22768;&#26126;&#21830;&#19994;&#36923;&#36753;&#26041;&#27861;&#12290;&#20320;&#24212;&#35813;&#22312;&#26144;&#23556;&#25991;&#20214;&#20013;&#25351;&#23450;&#36825;&#20123;&#25509;&#21475;&#65292;&#27604;&#22914;&#65306;        </p><pre class="programlisting">&lt;class name="eg.Cat" proxy="eg.ICat"&gt;    ......    &lt;subclass name="eg.DomesticCat" proxy="eg.IDomesticCat"&gt;        .....    &lt;/subclass&gt;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -