本篇內(nèi)容介紹了“Hibernate一對(duì)多關(guān)系的配置”的有關(guān)知識(shí),在實(shí)際案例的操作過(guò)程中,不少人都會(huì)遇到這樣的困境,接下來(lái)就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!
“只有客戶發(fā)展了,才有我們的生存與發(fā)展!”這是創(chuàng)新互聯(lián)建站的服務(wù)宗旨!把網(wǎng)站當(dāng)作互聯(lián)網(wǎng)產(chǎn)品,產(chǎn)品思維更注重全局思維、需求分析和迭代思維,在網(wǎng)站建設(shè)中就是為了建設(shè)一個(gè)不僅審美在線,而且實(shí)用性極高的網(wǎng)站。創(chuàng)新互聯(lián)對(duì)成都網(wǎng)站建設(shè)、成都做網(wǎng)站、網(wǎng)站制作、網(wǎng)站開發(fā)、網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站優(yōu)化、網(wǎng)絡(luò)推廣、探索永無(wú)止境。
一對(duì)多關(guān)系式Hibernate中的重要知識(shí)。感覺在Hibernate學(xué)習(xí)中最重要的也是最難的問(wèn)題就是配置文件了,對(duì)于Hibernate一對(duì)多關(guān)系的配置***.hbm.xml現(xiàn)總結(jié)如下:
﹤?xml version="1.0" encoding="gbk"?﹥ ﹤!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"﹥ ﹤hibernate-mapping package="此處填寫包文件" ﹥ ﹤class name="一對(duì)多中一的實(shí)體類的類名" table="所對(duì)應(yīng)的數(shù)據(jù)庫(kù)的表名" ﹥ ﹤id name="所對(duì)應(yīng)的實(shí)體類的屬性(id)" column="所對(duì)應(yīng)的數(shù)據(jù)表的字段(**_id)" unsaved-value="null" ﹥ ﹤generator class="native"/﹥ ﹤/id﹥ ﹤property name="對(duì)應(yīng)數(shù)據(jù)表中其他的字段" ﹥﹤/property﹥ ﹤set name="對(duì)應(yīng)實(shí)體類中的那個(gè)集合的屬性" inverse="true" lazy="true" cascade="save-update" ﹥ ﹤key column="對(duì)應(yīng)其外鍵的字段 "/﹥ ﹤one-to-many class="對(duì)應(yīng)一對(duì)多中多的實(shí)體類的類名"/﹥ ﹤/set﹥ ﹤/class﹥ ﹤class name="對(duì)應(yīng)一對(duì)多中多的實(shí)體類的類名" table="相對(duì)應(yīng)的數(shù)據(jù)表名" ﹥ ﹤id name="id" column="對(duì)應(yīng)表的主鍵字段名" unsaved-value="null" ﹥ ﹤generator class="native"/﹥ ﹤/id﹥ ﹤property name="對(duì)應(yīng)數(shù)據(jù)表中的其他字段" ﹥﹤/property﹥ ﹤many-to-one name="對(duì)應(yīng)一對(duì)多中一的實(shí)體類的屬性" column="對(duì)應(yīng)實(shí)體類中的那個(gè)集合的屬性" ﹥ ﹤/many-to-one﹥ ﹤/class﹥ ﹤/hibernate-mapping﹥ |
Hibernate一對(duì)多關(guān)系的配置代碼如下:
﹤!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"﹥ ﹤hibernate-mapping package="entity.test" ﹥ ﹤class name="Person" table="Person1" ﹥ ﹤id name="pid" column="p_id" unsaved-value="null" ﹥ ﹤generator class="native"/﹥ ﹤/id﹥ ﹤property name="name" ﹥﹤/property﹥ ﹤set name="computers" inverse="true" lazy="true" cascade="save-update" ﹥ ﹤key column="p_id"/﹥ ﹤one-to-many class="Computer"/﹥ ﹤/set﹥ ﹤/class﹥ ﹤class name="Computer" table="Computer" ﹥ ﹤id name="id" column="c_id" unsaved-value="null" ﹥ ﹤generator class="native"/﹥ ﹤/id﹥ ﹤property name="name" ﹥﹤/property﹥ ﹤many-to-one name="person" column="p_id" ﹥﹤/many-to-one﹥ ﹤/class﹥ ﹤/hibernate-mapping﹥ ﹤!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"﹥ ﹤hibernate-mapping package="entity.test" ﹥ ﹤class name="Person" table="Person1" ﹥ ﹤id name="pid" column="p_id" unsaved-value="null" ﹥ ﹤generator class="native"/﹥ ﹤/id﹥ ﹤property name="name" ﹥﹤/property﹥ ﹤set name="computers" inverse="true" lazy="true" cascade="save-update" ﹥ ﹤key column="p_id"/﹥ ﹤one-to-many class="Computer"/﹥ ﹤/set﹥ ﹤/class﹥ ﹤class name="Computer" table="Computer" ﹥ ﹤id name="id" column="c_id" unsaved-value="null" ﹥ ﹤generator class="native"/﹥ ﹤/id﹥ ﹤property name="name" ﹥﹤/property﹥ ﹤many-to-one name="person" column="p_id" ﹥﹤/many-to-one﹥ ﹤/class﹥ ﹤/hibernate-mapping﹥
整個(gè)的Hibernate技術(shù)就是圍繞著配置文件去發(fā)展。
“Hibernate一對(duì)多關(guān)系的配置”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!
本文標(biāo)題:Hibernate一對(duì)多關(guān)系的配置
轉(zhuǎn)載源于:http://aaarwkj.com/article8/jejdop.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站制作、搜索引擎優(yōu)化、網(wǎng)站設(shè)計(jì)公司、品牌網(wǎng)站設(shè)計(jì)、商城網(wǎng)站、關(guān)鍵詞優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)