H2O
BlogJava
首頁
新隨筆
聯(lián)系
聚合
管理
隨筆分類
java
(rss)
職業(yè)生涯o 0O
(rss)
文章分類
ajax(6)
(rss)
css(5)
(rss)
DataBase(9)
(rss)
ejb
(rss)
EXT(1)
(rss)
hibernate(4)
(rss)
java(14)
(rss)
javascript(13)
(rss)
spring(1)
(rss)
Spring+Struts+Hibernate整合(4)
(rss)
struts(4)
(rss)
webwork
(rss)
職業(yè)生涯規(guī)劃(1)
(rss)
那一天o 0 O(1)
(rss)
面試(1)
(rss)
文章檔案
2013年10月 (1)
2013年9月 (30)
2013年8月 (7)
2012年2月 (1)
2011年9月 (1)
2011年8月 (1)
2010年10月 (1)
2009年10月 (5)
2009年9月 (4)
2009年8月 (2)
2009年7月 (2)
2009年6月 (4)
2009年5月 (7)
2009年3月 (3)
2008年12月 (1)
2008年11月 (3)
2008年10月 (8)
2008年9月 (12)
2008年8月 (8)
相冊
程序相關(guān)
最新隨筆
1.?Debian / Ubuntu ---support UTF-8 locale/encoding
2.?Firefox Latest version
3.?重寫 FastJson 屬性過濾器
4.?freeradius for pptp
5.?Configuring Wildcard AlphaSSL from Centrio Host
6.?SSL
7.?some errors occured in complie firefox source
8.?checking for libnotify >= 0.4... Package libnotify was not found in the pkg-config search path.
9.?modify max_connections on mysql
10.?centos encoding
最新評論
1.?re: js獲取textarea中輸入文本的本選擇內(nèi)容
333333
--333
2.?re: 小毅原創(chuàng)---struts+spring+hibernate整合小例子
俄方
--預(yù)報呢
3.?re: some errors occured in complie firefox source
Thank you very very much for this post!
jelz
--Jelz
4.?re: some errors occured in complie firefox source
Thank you very much for this post!
Jelz
--Jelz
5.?re: Ibatis之LIKE用法[未登錄]
如果用'%$note$%'會造成sql注入的漏洞,使用拼接字符串的方法不錯
--KANG
hibernate關(guān)系映射(一對多)
Posted on 2008-08-21 12:00
H2O
閱讀(344)
評論(0)
編輯
收藏
所屬分類:
hibernate
客戶與訂單---一對多
package
com.yz.pojos;
import
java.util.HashSet;
import
java.util.Set;
/** */
/**
* Customer generated by MyEclipse Persistence Tools
*/
public
class
Customer
implements
java.io.Serializable
{
//
Fields
private
Integer cid;
private
String name;
private
String addr;
//
一個客戶可以有多個訂單,一對多關(guān)系。但是一個客戶不能有重復(fù)的訂單,所以用Set集合,set集合不允許出現(xiàn)重復(fù)值
//
set集合反映了一個客戶的所有訂單
private
Set orderses
=
new
HashSet(
0
);
//
Constructors
/** */
/**
default constructor
*/
public
Customer()
{
}
/** */
/**
minimal constructor
*/
public
Customer(String name)
{
this
.name
=
name;
}
/** */
/**
full constructor
*/
public
Customer(String name, String addr, Set orderses)
{
this
.name
=
name;
this
.addr
=
addr;
this
.orderses
=
orderses;
}
//
Property accessors
public
Integer getCid()
{
return
this
.cid;
}
public
void
setCid(Integer cid)
{
this
.cid
=
cid;
}
public
String getName()
{
return
this
.name;
}
public
void
setName(String name)
{
this
.name
=
name;
}
public
String getAddr()
{
return
this
.addr;
}
public
void
setAddr(String addr)
{
this
.addr
=
addr;
}
public
Set getOrderses()
{
return
this
.orderses;
}
public
void
setOrderses(Set orderses)
{
this
.orderses
=
orderses;
}
}
<?
xml version="1.0" encoding="utf-8"
?>
<!
DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"
>
<!--
Mapping file autogenerated by MyEclipse Persistence Tools
-->
<
hibernate-mapping
>
<
class
name
="com.yz.pojos.Customer"
table
="customer"
lazy
="false"
>
<
id
name
="cid"
type
="java.lang.Integer"
>
<
column
name
="cid"
/>
<
generator
class
="native"
/>
</
id
>
<
property
name
="name"
type
="java.lang.String"
>
<
column
name
="name"
length
="20"
not-null
="true"
/>
</
property
>
<
property
name
="addr"
type
="java.lang.String"
>
<
column
name
="addr"
length
="50"
/>
</
property
>
<!--
set集合保存該客戶所有的訂單,通過鍵cid查找訂單
-->
<
set
name
="orderses"
lazy
="true"
cascade
="delete"
inverse
="true"
>
<
key
>
<
column
name
="cid"
not-null
="true"
/>
</
key
>
<
one-to-many
class
="com.yz.pojos.Orders"
/>
</
set
>
</
class
>
</
hibernate-mapping
>
訂單與客戶---多對一
package
com.yz.pojos;
import
java.util.Date;
/** */
/**
* Orders generated by MyEclipse Persistence Tools
*/
public
class
Orders
implements
java.io.Serializable
{
//
Fields
private
Integer oid;
//
在多個訂單中,每個訂單只能屬于一個客戶,屬于 多對一關(guān)系,所以要告訴每個訂單屬于哪一個客戶對象
private
Customer customer;
private
Date odate;
//
Constructors
/** */
/**
default constructor
*/
public
Orders()
{
}
/** */
/**
full constructor
*/
public
Orders(Customer customer, Date odate)
{
this
.customer
=
customer;
this
.odate
=
odate;
}
//
Property accessors
public
Integer getOid()
{
return
this
.oid;
}
public
void
setOid(Integer oid)
{
this
.oid
=
oid;
}
public
Customer getCustomer()
{
return
this
.customer;
}
public
void
setCustomer(Customer customer)
{
this
.customer
=
customer;
}
public
Date getOdate()
{
return
this
.odate;
}
public
void
setOdate(Date odate)
{
this
.odate
=
odate;
}
}
<?
xml version="1.0" encoding="utf-8"
?>
<!
DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"
>
<!--
Mapping file autogenerated by MyEclipse Persistence Tools
-->
<
hibernate-mapping
>
<
class
name
="com.yz.pojos.Orders"
table
="orders"
catalog
="ssh"
>
<
id
name
="oid"
type
="java.lang.Integer"
>
<
column
name
="oid"
/>
<
generator
class
="native"
/>
</
id
>
<!--
訂單與客戶多對一,告訴訂單所關(guān)聯(lián)的客戶是誰
-->
<
many-to-one
name
="customer"
class
="com.yz.pojos.Customer"
fetch
="select"
>
<
column
name
="cid"
not-null
="true"
/>
</
many-to-one
>
<
property
name
="odate"
type
="java.util.Date"
insert
="true"
>
<
column
name
="odate"
length
="19"
not-null
="true"
/>
</
property
>
</
class
>
</
hibernate-mapping
>
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發(fā)表評論。
網(wǎng)站導(dǎo)航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
相關(guān)文章:
hibernate一對一完美版
hibernate關(guān)系映射(一對一)
hibernate關(guān)系映射(多對多)
hibernate關(guān)系映射(一對多)
評論排行榜
閱讀排行榜
posts - 0, comments - 21, trackbacks - 0, articles - 101
Copyright © H2O
主站蜘蛛池模板:
成人最新午夜免费视频
|
亚洲kkk4444在线观看
|
四虎成人精品在永久免费
|
91麻豆国产免费观看
|
一个人看的免费高清视频日本
|
2019亚洲午夜无码天堂
|
久久亚洲精品成人777大小说
|
婷婷综合缴情亚洲狠狠尤物
|
最近中文字幕免费mv视频7
|
伊人久久免费视频
|
jizz免费一区二区三区
|
亚洲成a人片在线不卡一二三区
|
亚洲网站免费观看
|
亚洲AV无码久久
|
在线观看亚洲精品福利片
|
国产在线不卡免费播放
|
拨牐拨牐x8免费
|
ww在线观视频免费观看
|
国产三级在线免费
|
中文在线免费视频
|
一级毛片大全免费播放下载
|
在线91精品亚洲网站精品成人
|
亚洲狠狠成人综合网
|
亚洲午夜久久久精品电影院
|
久久亚洲中文字幕精品有坂深雪
|
亚洲人成电影网站色www
|
亚洲色欲www综合网
|
亚洲国产一区二区三区青草影视
|
久久九九亚洲精品
|
九月丁香婷婷亚洲综合色
|
亚洲午夜福利717
|
亚洲伊人久久综合中文成人网
|
免费大黄网站在线观看
|
国产成人无码免费视频97
|
国产自产拍精品视频免费看
|
蜜臀91精品国产免费观看
|
精品免费国产一区二区
|
在线免费观看国产视频
|
亚洲嫩草影院在线观看
|
亚洲人成网站在线播放影院在线
|
亚洲AV乱码一区二区三区林ゆな
|