?數據庫結構
CREATE
?
TABLE
?`team3`?(
??`id`?
varchar
(
50
)?
NOT
?
NULL
,
??`name`?
varchar
(
50
)?
default
?
NULL
,
??
PRIMARY
?
KEY
??(`id`)
)?ENGINE
=
InnoDB?
DEFAULT
?CHARSET
=
gb2312;
CREATE
?
TABLE
?`member3`?(
??`id`?
varchar
(
50
)?
NOT
?
NULL
,
??`name`?
varchar
(
50
)?
default
?
NULL
,
??`age`?
varchar
(
50
)?
default
?
NULL
,
??`role`?
varchar
(
50
)?
default
?
NULL
,
??`scene`?
varchar
(
50
)?
default
?
NULL
,
??`team`?
varchar
(
50
)?
default
?
NULL
,
??`bestChoice`?
varchar
(
50
)?
default
?
NULL
,
??
PRIMARY
?
KEY
??(`id`)
)?ENGINE
=
InnoDB?
DEFAULT
?CHARSET
=
gb2312;
package
?mapcompoistindex;
import
?java.util.HashMap;
import
?java.util.Map;
public
?
class
?Team?
{
???
private
?String?id;
???
private
?String?name;
???
private
?Map?members
=
new
?HashMap();
public
?String?getId()?
{
????
return
?id;
}
public
?
void
?setId(String?id)?
{
????
this
.id?
=
?id;
}
public
?Map?getMembers()?
{
????
return
?members;
}
public
?
void
?setMembers(Map?members)?
{
????
this
.members?
=
?members;
}
public
?String?getName()?
{
????
return
?name;
}
public
?
void
?setName(String?name)?
{
????
this
.name?
=
?name;
}
}
package
?mapcompoistindex;
import
?java.util.HashMap;
import
?java.util.Map;
import
?java.util.Set;
public
?
class
?Member?
{
???
private
?String?id;
???
private
?String?name;
???
private
?Position?postition;
???
private
?Team?team;
???
private
?String?age;
public
?String?getAge()?
{
????
return
?age;
}
public
?
void
?setAge(String?age)?
{
????
this
.age?
=
?age;
}
public
?String?getName()?
{
????
return
?name;
}
public
?
void
?setName(String?name)?
{
????
this
.name?
=
?name;
}
public
?Position?getPostition()?
{
????
return
?postition;
}
public
?
void
?setPostition(Position?postition)?
{
????
this
.postition?
=
?postition;
}
public
?String?getId()?
{
????
return
?id;
}
public
?
void
?setId(String?id)?
{
????
this
.id?
=
?id;
}
public
?Team?getTeam()?
{
????
return
?team;
}
public
?
void
?setTeam(Team?team)?
{
????
this
.team?
=
?team;
}
}
package
?mapcompoistindex;
public
?
class
?Position?
{
??
private
?String?role;
??
private
?String?scene;
??
private
?Member?bestChoice;
public
?Member?getBestChoice()?
{
????
return
?bestChoice;
}
public
?
void
?setBestChoice(Member?bestChoice)?
{
????
this
.bestChoice?
=
?bestChoice;
}
public
?String?getRole()?
{
????
return
?role;
}
public
?
void
?setRole(String?role)?
{
????
this
.role?
=
?role;
}
public
?String?getScene()?
{
????
return
?scene;
}
public
?
void
?setScene(String?scene)?
{
????
this
.scene?
=
?scene;
}
}
映射文件:
<?
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?-?Hibernate?Tools
-->
<
hibernate-mapping?
package
="mapcompoistindex"
>
????
<
class?
name
="Team"
?table
="team3"
>
???????
<
id?
name
="id"
?column
="id"
>
?????????
<
generator?
class
="uuid.hex"
></
generator
>
???????
</
id
>
???????
<
property?
name
="name"
?column
="name"
/>
???????
<
map?
name
="members"
?inverse
="false"
?cascade
="save-update"
>
??????????
<
key?
column
="team"
/>
???????????
<
composite-index?
class
="Position"
>
?????????????
<
key-property?
name
="role"
></
key-property
>
?????????????
<
key-property?
name
="scene"
></
key-property
>
?????????????
<
key-many-to-one?
name
="bestChoice"
?class
="Member"
></
key-many-to-one
>
???????????
</
composite-index
>
???????????
<
one-to-many?
class
="Member"
/>
???????
</
map
>
????
</
class
>
</
hibernate-mapping
>
<?
xml?version="1.0"?encoding="utf-8"
?>

















實體類:
?













































































































映射文件:



























更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
