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

📄 example-mappings.html

📁 图象处理
💻 HTML
📖 第 1 页 / 共 2 页
字号:
        &lt;property name="alias"/&gt;        &lt;one-to-one name="person" constrained="true"/&gt;        &lt;set name="works" table="author_work" inverse="true" lazy="true"&gt;            &lt;key column="author_id"/&gt;            &lt;many-to-many class="Work" column="work_id"/&gt;        &lt;/set&gt;    &lt;/class&gt;    &lt;class name="Person" table="persons"&gt;        &lt;id name="id" column="id"&gt;            &lt;generator class="native"/&gt;        &lt;/id&gt;        &lt;property name="name"/&gt;    &lt;/class&gt;&lt;/hibernate-mapping&gt;</pre><p>        &#22312;&#36825;&#20010;&#26144;&#23556;&#20013;&#26377;&#22235;&#20010;&#34920;&#12290;<tt class="literal">works</tt>&#65292;<tt class="literal">authors</tt>&#21644;<tt class="literal">persons</tt>&#20998;&#21035;&#23384;&#25918;&#33879;&#20316;&#12289;&#20316;&#32773;&#20197;&#21450;&#20154;&#30340;&#25968;&#25454;&#12290;<tt class="literal">author_work</tt>&#26159;&#20851;&#32852;&#34920;&#65292;&#25226;&#20316;&#32773;&#19982;&#33879;&#20316;&#20851;&#32852;&#36215;&#26469;&#12290;&#20197;&#19979;&#26159;&#30001;<tt class="literal">SchemaExport</tt>&#29983;&#25104;&#30340;&#34920;&#32467;&#26500;&#12290;    </p><pre class="programlisting">create table works (    id BIGINT not null generated by default as identity,     tempo FLOAT,     genre VARCHAR(255),     text INTEGER,     title VARCHAR(255),     type CHAR(1) not null,     primary key (id))create table author_work (    author_id BIGINT not null,     work_id BIGINT not null,     primary key (work_id, author_id))create table authors (    id BIGINT not null generated by default as identity,     alias VARCHAR(255),     primary key (id))create table persons (    id BIGINT not null generated by default as identity,     name VARCHAR(255),     primary key (id))alter table authors     add constraint authorsFK0 foreign key (id) references personsalter table author_work     add constraint author_workFK0 foreign key (author_id) references authorsalter table author_work    add constraint author_workFK1 foreign key (work_id) references works</pre></div><div class="sect1" lang="zh-cn"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="example-mappings-customerorderproduct"></a>18.3.&nbsp;&#23458;&#25143;&#65295;&#35746;&#21333;&#65295;&#20135;&#21697;(Customer/Order/Product)</h2></div></div><div></div></div><p>	    &#25509;&#19979;&#26469;&#30340;&#20363;&#23376;&#26159;&#20851;&#20110;<tt class="literal">Customer</tt>&#12289;<tt class="literal">Order</tt>&#12289;<tt class="literal">LineItem</tt>&#21644;<tt class="literal">Product</tt>&#12290;<tt class="literal">Customer</tt>&#21644;<tt class="literal">Order</tt>&#20043;&#38388;&#26159;&#19968;&#23545;&#22810;&#30340;&#20851;&#32852;&#12290;&#37027;&#20040;<tt class="literal">Order</tt>&#65295;<tt class="literal">LineItem</tt>&#65295;<tt class="literal">Product</tt>&#20043;&#38388;&#30340;&#20851;&#32852;&#24590;&#20040;&#34920;&#31034;&#21602;&#65311;&#25105;&#20204;&#21487;&#20197;&#25226;<tt class="literal">LineItem</tt>&#20316;&#20026;&#20851;&#32852;&#34920;&#26469;&#34920;&#31034;<tt class="literal">Order</tt>&#21644;<tt class="literal">Product</tt>&#20043;&#38388;&#22810;&#23545;&#22810;&#20851;&#32852;&#65292;&#22312;Hibernate&#37324;&#65292;&#23427;&#34987;&#31216;&#20026;&#32452;&#21512;&#20803;&#32032;&#65288;composite element&#65289;&#12290;	</p><div class="mediaobject" align="center"><img src="../shared/images/CustomerOrderProduct.gif" align="middle"></div><p>	    &#26144;&#23556;&#25991;&#26723;&#65306;	</p><pre class="programlisting">&lt;hibernate-mapping&gt;    &lt;class name="Customer" table="customers"&gt;        &lt;id name="id"&gt;            &lt;generator class="native"/&gt;        &lt;/id&gt;        &lt;property name="name"/&gt;        &lt;set name="orders" inverse="true" lazy="true"&gt;            &lt;key column="customer_id"/&gt;            &lt;one-to-many class="Order"/&gt;        &lt;/set&gt;    &lt;/class&gt;    &lt;class name="Order" table="orders"&gt;        &lt;id name="id"&gt;            &lt;generator class="native"/&gt;        &lt;/id&gt;        &lt;property name="date"/&gt;        &lt;many-to-one name="customer" column="customer_id"/&gt;        &lt;list name="lineItems" table="line_items" lazy="true"&gt;            &lt;key column="order_id"/&gt;            &lt;index column="line_number"/&gt;            &lt;composite-element class="LineItem"&gt;                &lt;property name="quantity"/&gt;                &lt;many-to-one name="product" column="product_id"/&gt;            &lt;/composite-element&gt;        &lt;/list&gt;    &lt;/class&gt;    &lt;class name="Product" table="products"&gt;        &lt;id name="id"&gt;            &lt;generator class="native"/&gt;        &lt;/id&gt;        &lt;property name="serialNumber"/&gt;    &lt;/class&gt;&lt;/hibernate-mapping&gt;</pre><p>        <tt class="literal">customers</tt>&#12289;<tt class="literal">orders</tt>&#12289;<tt class="literal">line_items</tt>&#21644;<tt class="literal">products</tt>&#20998;&#21035;&#23384;&#25918;&#23458;&#25143;&#12289;&#35746;&#21333;&#12289;&#35746;&#21333;&#39033;&#20197;&#21450;&#20135;&#21697;&#30340;&#25968;&#25454;&#12290;<tt class="literal">line_items</tt>&#20316;&#20026;&#20851;&#32852;&#34920;&#65292;&#25226;&#35746;&#21333;&#21644;&#20135;&#21697;&#20851;&#32852;&#36215;&#26469;&#12290;    </p><pre class="programlisting">create table customers (    id BIGINT not null generated by default as identity,     name VARCHAR(255),     primary key (id))create table orders (    id BIGINT not null generated by default as identity,     customer_id BIGINT,     date TIMESTAMP,     primary key (id))create table line_items (    line_number INTEGER not null,     order_id BIGINT not null,     product_id BIGINT,     quantity INTEGER,     primary key (order_id, line_number))create table products (    id BIGINT not null generated by default as identity,     serialNumber VARCHAR(255),     primary key (id))alter table orders     add constraint ordersFK0 foreign key (customer_id) references customersalter table line_items    add constraint line_itemsFK0 foreign key (product_id) references productsalter table line_items    add constraint line_itemsFK1 foreign key (order_id) references orders</pre></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="example-weblog.html">&#19978;&#19968;&#39029;</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="index.html">&#19978;&#19968;&#32423;</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="best-practices.html">&#19979;&#19968;&#39029;</a></td></tr><tr><td width="40%" align="left" valign="top">&#31532;&nbsp;17&nbsp;&#31456;&nbsp;&#31034;&#20363;&#65306;Weblog &#24212;&#29992;&#31243;&#24207;&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">&#36215;&#22987;&#39029;</a></td><td width="40%" align="right" valign="top">&nbsp;&#31532;&nbsp;19&nbsp;&#31456;&nbsp;&#26368;&#20339;&#23454;&#36341;(Best Practices)</td></tr></table></div></body></html>

⌨️ 快捷键说明

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