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

📄 tutorial.html

📁 是一个中文的Hibernate库文档
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<html><head>      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">   <title>&#31532;&nbsp;2&nbsp;&#31456;&nbsp;	Hibernate&#20837;&#38376;	</title><link rel="stylesheet" href="../shared/css/html.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.65.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="quickstart.html" title="&#31532;&nbsp;1&nbsp;&#31456;&nbsp;&#22312;Tomcat&#20013;&#24555;&#36895;&#19978;&#25163;"><link rel="next" href="architecture.html" title="&#31532;&nbsp;3&nbsp;&#31456;&nbsp;&#20307;&#31995;&#32467;&#26500;(Architecture)"></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">&#31532;&nbsp;2&nbsp;&#31456;&nbsp;	Hibernate&#20837;&#38376;	</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="quickstart.html">&#19978;&#19968;&#39029;</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="architecture.html">&#19979;&#19968;&#39029;</a></td></tr></table><hr></div><div class="chapter" lang="zh-cn"><div class="titlepage"><div><div><h2 class="title"><a name="tutorial"></a>&#31532;&nbsp;2&nbsp;&#31456;&nbsp;	Hibernate&#20837;&#38376;	</h2></div></div><div></div></div><div class="sect1" lang="zh-cn"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="tutorial-intro"></a>2.1.&nbsp;		&#21069;&#35328;	</h2></div></div><div></div></div><p>	     &#26412;&#31456;&#26159;&#38754;&#21521;Hibernate&#21021;&#23398;&#32773;&#30340;&#19968;&#20010;&#20171;&#32461;&#25945;&#31243;&#12290;&#25105;&#20204;&#23558;&#20351;&#29992;&#23481;&#26131;&#29702;&#35299;&#30340;&#26041;&#24335;&#65292;&#24320;&#21457;&#19968;&#20010;&#20351;&#29992;&#39547;&#30041;&#20869;&#23384;&#24335;(in-memory)&#25968;&#25454;&#24211;&#30340;&#31616;&#21333;&#21629;&#20196;&#34892;&#31243;&#24207;&#12290;        </p><p>		&#26412;&#25945;&#31243;&#26159;&#38754;&#21521;Hibernate&#21021;&#23398;&#32773;&#65292;&#20294;&#26159;&#38656;&#35201;&#19968;&#23450;&#30340;Java&#21644;SQL&#30693;&#35782;&#12290;		&#23427;&#22312;Michael Goegl&#25152;&#20889;&#30340;&#19968;&#20010;&#25945;&#31243;&#30340;&#22522;&#30784;&#19978;&#23436;&#25104;&#30340;&#12290;&#25105;&#20204;&#20351;&#29992;&#30340;&#31532;&#19977;&#26041;&#24211;&#25991;&#20214;&#26159;&#25903;&#25345;JDK 1.4&#21644;5.0&#12290;&#22914;&#26524;&#20320;&#35201;&#20351;&#29992;JDK1.3&#65292;&#21487;&#33021;&#20250;&#38656;&#35201;&#20854;&#23427;&#30340;&#24211;&#12290;        </p></div><div class="sect1" lang="zh-cn"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="tutorial-firstapp"></a>2.2.&nbsp;		&#31532;&#19968;&#37096;&#20998; &#65293; &#31532;&#19968;&#20010;Hibernate&#31243;&#24207;		</h2></div></div><div></div></div><p>		&#39318;&#20808;&#25105;&#20204;&#23558;&#21019;&#24314;&#19968;&#20010;&#31616;&#21333;&#30340;&#25511;&#21046;&#21488;(console-based)Hibernate&#31243;&#24207;&#12290;&#25105;&#20204;&#20351;&#29992;&#20869;&#32622;&#25968;&#25454;&#24211;(in-memory database)		(HSQL DB)&#65292;&#25152;&#20197;&#25105;&#20204;&#19981;&#24517;&#23433;&#35013;&#20219;&#20309;&#25968;&#25454;&#24211;&#26381;&#21153;&#22120;&#12290;        </p><p>		&#35753;&#25105;&#20204;&#20551;&#35774;&#25105;&#20204;&#24076;&#26395;&#26377;&#19968;&#20010;&#23567;&#31243;&#24207;&#21487;&#20197;&#20445;&#23384;&#25105;&#20204;&#24076;&#26395;&#20851;&#27880;&#30340;&#20107;&#20214;&#65288;Event&#65289;&#21644;&#36825;&#20123;&#20107;&#20214;&#30340;&#20449;&#24687;&#12290;		&#65288;&#35793;&#32773;&#27880;&#65306;&#22312;&#26412;&#25945;&#31243;&#30340;&#21518;&#38754;&#37096;&#20998;&#65292;&#25105;&#20204;&#23558;&#30452;&#25509;&#20351;&#29992;Event&#32780;&#19981;&#26159;&#23427;&#30340;&#20013;&#25991;&#32763;&#35793;&#8220;&#20107;&#20214;&#8221;&#65292;&#20197;&#20813;&#28151;&#28102;&#12290;&#65289;        </p><p>		&#25105;&#20204;&#20570;&#30340;&#31532;&#19968;&#20214;&#20107;&#26159;&#24314;&#31435;&#25105;&#20204;&#30340;&#24320;&#21457;&#30446;&#24405;&#65292;&#24182;&#25226;&#25152;&#26377;&#38656;&#35201;&#29992;&#21040;&#30340;Java&#24211;&#25991;&#20214;&#25918;&#36827;&#21435;&#12290;		&#20174;Hibernate&#32593;&#31449;&#30340;&#19979;&#36733;&#39029;&#38754;&#19979;&#36733;Hibernate&#20998;&#21457;&#29256;&#26412;&#12290;		&#35299;&#21387;&#32553;&#21253;&#24182;&#25226;<tt class="literal">/lib</tt>&#19979;&#38754;&#30340;&#25152;&#26377;&#24211;&#25991;&#20214;&#25918;&#21040;&#25105;&#20204;&#26032;&#30340;&#24320;&#21457;&#30446;&#24405;&#19979;&#38754;&#30340;<tt class="literal">/lib</tt>&#30446;&#24405;&#19979;&#38754;&#12290;		&#30475;&#36215;&#26469;&#23601;&#20687;&#36825;&#26679;&#65306;        </p><pre class="programlisting">.+lib  antlr.jar  cglib-full.jar  asm.jar  asm-attrs.jars  commons-collections.jar  commons-logging.jar  ehcache.jar  hibernate3.jar  jta.jar  dom4j.jar  log4j.jar </pre><p>            This is the minimum set of required libraries (note that we also copied            hibernate3.jar, the main archive) for Hibernate. See the <tt class="literal">README.txt</tt> file            in the <tt class="literal">lib/</tt> directory of the Hibernate distribution for more information            about required and optional third-party libraries. (Actually, Log4j is not            required but preferred by many developers.)		&#36825;&#20010;&#26159;Hibernate&#36816;&#34892;&#25152;&#38656;&#35201;&#30340;&#26368;&#23567;&#24211;&#25991;&#20214;&#38598;&#21512;&#65288;&#27880;&#24847;&#25105;&#20204;&#20063;&#25335;&#36125;&#20102;Hibernate3.jar&#65292;&#36825;&#20010;&#26159;&#26368;&#37325;&#35201;&#30340;&#24211;&#65289;&#12290;		&#21487;&#20197;&#22312;Hibernate&#20998;&#21457;&#29256;&#26412;&#30340;<tt class="literal">lib/</tt>&#30446;&#24405;&#19979;&#26597;&#30475;<tt class="literal">README.txt</tt>&#65292;&#20197;&#33719;&#21462;&#26356;&#22810;&#20851;&#20110;&#25152;&#38656;&#21644;&#21487;&#36873;&#30340;&#31532;&#19977;&#26041;&#24211;&#25991;&#20214;&#20449;&#24687;		&#65288;&#20107;&#23454;&#19978;&#65292;Log4j&#24182;&#19981;&#26159;&#24517;&#39035;&#30340;&#24211;&#25991;&#20214;&#20294;&#26159;&#35768;&#22810;&#24320;&#21457;&#32773;&#37117;&#21916;&#27426;&#29992;&#23427;&#65289;&#12290;        </p><p>		&#25509;&#19979;&#26469;&#25105;&#20204;&#21019;&#24314;&#19968;&#20010;&#31867;&#65292;&#29992;&#26469;&#20195;&#34920;&#37027;&#20123;&#25105;&#20204;&#24076;&#26395;&#20648;&#23384;&#22312;&#25968;&#25454;&#24211;&#37324;&#38754;&#30340;event.        </p><div class="sect2" lang="zh-cn"><div class="titlepage"><div><div><h3 class="title"><a name="tutorial-firstapp-firstclass"></a>2.2.1.&nbsp;		&#31532;&#19968;&#20010;class		</h3></div></div><div></div></div><p>		&#25105;&#20204;&#30340;&#31532;&#19968;&#20010;&#25345;&#20037;&#21270;&#31867;&#26159;	&#19968;&#20010;&#31616;&#21333;&#30340;JavaBean class&#65292;&#24102;&#26377;&#19968;&#20123;&#31616;&#21333;&#30340;&#23646;&#24615;&#65288;property&#65289;&#12290;		&#35753;&#25105;&#20204;&#26469;&#30475;&#19968;&#19979;&#20195;&#30721;&#65306;            </p><pre class="programlisting">import java.util.Date;public class Event {    private Long id;    private String title;    private Date date;    Event() {}    public Long getId() {        return id;    }    private void setId(Long id) {        this.id = id;    }    public Date getDate() {        return date;    }    public void setDate(Date date) {        this.date = date;    }    public String getTitle() {        return title;    }    public void setTitle(String title) {        this.title = title;    }}</pre><p>		&#20320;&#21487;&#20197;&#30475;&#21040;&#36825;&#20010;class&#23545;&#23646;&#24615;&#65288;property&#65289;&#30340;&#23384;&#21462;&#26041;&#27861;&#65288;getter and setter method&#65289;		&#20351;&#29992;&#26631;&#20934;&#30340;JavaBean&#21629;&#21517;&#32422;&#23450;&#65292;&#21516;&#26102;&#25226;&#20869;&#37096;&#23383;&#27573;&#65288;field&#65289;&#38544;&#34255;&#36215;&#26469;&#65288;private visibility&#65289;&#12290;		&#36825;&#20010;&#26159;&#20010;&#21463;&#25512;&#33616;&#30340;&#35774;&#35745;&#26041;&#24335;&#65292;&#20294;&#24182;&#19981;&#26159;&#24517;&#39035;&#36825;&#26679;&#20570;&#12290;		Hibernate&#20063;&#21487;&#20197;&#30452;&#25509;&#35775;&#38382;&#36825;&#20123;&#23383;&#27573;&#65288;field&#65289;&#65292;&#32780;&#20351;&#29992;&#35775;&#38382;&#26041;&#27861;&#65288;accessor method&#65289;&#30340;&#22909;&#22788;&#26159;&#25552;&#20379;&#20102;&#31243;&#24207;&#37325;&#26500;&#30340;&#26102;&#20505;&#20581;&#22766;&#24615;&#65288;robustness&#65289;&#12290;            </p><p>                <tt class="literal">id</tt> &#23646;&#24615;&#65288;property&#65289; &#20026;&#19968;&#20010;Event&#23454;&#20363;&#25552;&#20379;&#26631;&#35782;&#23646;&#24615;&#65288;identifier property&#65289;&#30340;&#20540;&#65293;                &#22914;&#26524;&#25105;&#20204;&#24076;&#26395;&#20351;&#29992;Hibernate&#30340;&#25152;&#26377;&#29305;&#24615;&#65292;&#37027;&#20040;&#25105;&#20204;&#25152;&#26377;&#30340;&#25345;&#20037;&#24615;&#23454;&#20307;&#31867;&#65288;persistent entity class&#65289;(&#36825;&#37324;&#20063;&#21253;&#25324;&#19968;&#20123;&#27425;&#35201;&#20381;&#36182;&#31867;) 		  &#37117;&#38656;&#35201;&#19968;&#20010;&#26631;&#35782;&#23646;&#24615;&#65288;identifier property&#65289;&#12290;&#32780;&#20107;&#23454;&#19978;&#65292;&#22823;&#22810;&#25968;&#24212;&#29992;&#31243;&#24207;&#65288;&#29305;&#21035;&#26159;web&#24212;&#29992;&#31243;&#24207;&#65289;&#37117;&#38656;&#35201;&#35782;&#21035;&#29305;&#23450;&#30340;&#23545;&#35937;&#65292;&#25152;&#20197;&#20320;&#24212;&#35813;		  &#32771;&#34385;&#20351;&#29992;&#26631;&#35782;&#23646;&#24615;&#32780;&#19981;&#26159;&#25226;&#23427;&#24403;&#20316;&#19968;&#31181;&#38480;&#21046;&#12290;&#28982;&#32780;&#65292;&#25105;&#20204;&#36890;&#24120;&#19981;&#20250;&#30452;&#25509;&#25805;&#20316;&#19968;&#20010;&#23545;&#35937;&#30340;&#26631;&#35782;&#31526;&#65288;identifier&#65289;&#65292; 		&#22240;&#27492;&#26631;&#35782;&#31526;&#30340;setter&#26041;&#27861;&#24212;&#35813;&#34987;&#22768;&#26126;&#20026;&#31169;&#26377;&#30340;&#65288;private&#65289;&#12290;&#36825;&#26679;&#24403;&#19968;&#20010;&#23545;&#35937;&#34987;&#20445;&#23384;&#30340;&#26102;&#20505;&#65292;&#21482;&#26377;Hibernate&#21487;&#20197;&#20026;&#23427;&#20998;&#37197;&#26631;&#35782;&#31526;&#12290;		&#20320;&#20250;&#21457;&#29616;Hibernate&#21487;&#20197;&#30452;&#25509;&#35775;&#38382;&#34987;&#22768;&#26126;&#20026;public&#65292;private&#21644;protected&#31561;&#19981;&#21516;&#32423;&#21035;&#35775;&#38382;&#25511;&#21046;&#30340;&#26041;&#27861;&#65288;accessor method&#65289;&#21644;&#23383;&#27573;&#65288;field&#65289;&#12290;		&#25152;&#20197;&#36873;&#25321;&#21738;&#31181;&#26041;&#24335;&#26469;&#35775;&#38382;&#23646;&#24615;&#26159;&#23436;&#20840;&#21462;&#20915;&#20110;&#20320;&#65292;&#20320;&#21487;&#20197;&#20351;&#20320;&#30340;&#36873;&#25321;&#19982;&#20320;&#30340;&#31243;&#24207;&#35774;&#35745;&#30456;&#21563;&#21512;&#12290;            </p><p>		&#25152;&#26377;&#30340;&#25345;&#20037;&#31867;&#65288;persistent classes&#65289;&#37117;&#35201;&#27714;&#26377;&#26080;&#21442;&#30340;&#26500;&#36896;&#22120;&#65288;no-argument constructor&#65289;&#65307;		&#22240;&#20026;Hibernate&#24517;&#39035;&#35201;&#20351;&#29992;Java&#21453;&#23556;&#26426;&#21046;&#65288;Reflection&#65289;&#26469;&#23454;&#20363;&#21270;&#23545;&#35937;&#12290;&#26500;&#36896;&#22120;&#65288;constructor&#65289;&#30340;&#35775;&#38382;&#25511;&#21046;&#21487;&#20197;&#26159;&#31169;&#26377;&#30340;&#65288;private&#65289;&#65292;		&#28982;&#32780;&#24403;&#29983;&#25104;&#36816;&#34892;&#26102;&#20195;&#29702;&#65288;runtime proxy&#65289;&#30340;&#26102;&#20505;&#23558;&#35201;&#27714;&#20351;&#29992;&#33267;&#23569;&#26159;package&#32423;&#21035;&#30340;&#35775;&#38382;&#25511;&#21046;&#65292;&#36825;&#26679;&#22312;&#27809;&#26377;&#23383;&#33410;&#30721;&#32534;&#20837;		&#65288;bytecode instrumentation&#65289;&#30340;&#24773;&#20917;&#19979;&#65292;&#20174;&#25345;&#20037;&#21270;&#31867;&#37324;&#33719;&#21462;&#25968;&#25454;&#20250;&#26356;&#26377;&#25928;&#29575;&#19968;&#20123;&#12290;            </p><p>		  &#25105;&#20204;&#25226;&#36825;&#20010;Java&#28304;&#20195;&#30721;&#25991;&#20214;&#25918;&#21040;&#25105;&#20204;&#30340;&#24320;&#21457;&#30446;&#24405;&#19979;&#38754;&#19968;&#20010;&#21483;&#20570;<tt class="literal">src</tt>&#30340;&#30446;&#24405;&#37324;&#12290;		  &#36825;&#20010;&#30446;&#24405;&#29616;&#22312;&#24212;&#35813;&#30475;&#36215;&#26469;&#20687;&#36825;&#26679;&#65306;            </p><pre class="programlisting">.+lib  &lt;Hibernate and third-party libraries&gt;+src  Event.java</pre><p>		  &#22312;&#19979;&#19968;&#27493;&#37324;&#65292;&#25105;&#20204;&#23558;&#25226;&#36825;&#20010;&#25345;&#20037;&#31867;&#65288;persisten class&#65289;&#30340;&#20449;&#24687;&#36890;&#30693;Hibernate

⌨️ 快捷键说明

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