atitit. orm mapping cfg 映射配置(3)-------hbnt one2maney cfg,atititorm

來源:互聯網
上載者:User

atitit. orm mapping cfg 映射配置(3)-------hbnt one2maney cfg,atititorm

atitit. orm mapping cfg  映射配置(3)-------hbnt one2maney  cfg

 

1. 建立list 1

2. 配置xml 1

3. Hibernate中Set和List的配置 1

4. Bag(結合了List與Set), 2

 

1. 建立list

/**

 * 集合屬性只能以介面聲明。例如在下面的代碼中,schools的類型只能是List,不能是ArrayList,但該集合屬性必須使用實作類別完成初始化.

 */

public List list=new ArrayList();

 

2. 配置xml

    <!-- o7o ati -->

         <!-- many開頭的是代表該表持有外鍵 -->      

          <!-- key是外鍵 -->    <!--     list是有序集合,因此持久化類到資料庫時必須增加一列來表示集合元素的次序

          。list元素要求list-index的子項目來映射有序集合的次序列..jieg order col must in table def..

          yaosi b tigon column,,zeu def sh "idx"

             list_order int not null,

          -->  

<list name="list" >

<key column="programme_id"/><list-index column="play_order"></list-index>

<one-to-many class="com.focustar.programme.entity.GvProgrammeDetail"/>

</list>

 

作者:: 老哇的爪子 Attilax 艾龍,  EMAIL:1466519819@qq.com

轉載請註明來源: http://blog.csdn.net/attilax

 

3. Hibernate中Set和List的配置

(2010-11-16 14:11:57)

轉載▼

標籤:

it

分類:學習總結

· Set映射:

<set name="addrs" table="EMAIL"> 

<key column="C_ID" />

<element type="string" column="ADDRESS" />

</set>

· List映射:

<list name="addrs" table="EMAIL">

<key column="C_ID" />

<index column="LISTINDEX">(與Set映射的一點區別在於List有一個描述下標的欄位)

<element type="string" column="ADDRESS"/>

</list>

 com.microsoft.sqlserver.jdbc.SQLServerException: 列名 'idx' 無效。

 

 

4. Bag(結合了List與Set),

可以重複且沒有順序的一種集合,是Hibernate提供的。HIbernate使用jdk的List類比Bag。其配置與Hibernate映射List時基本相同。 


用hibernate寫對應檔hibernatecfgxml時,hibernate-mapping-30dtd要匯入到哪?

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
 
spring+hibernate,配置hibernatecfgxml中的mapping報錯

Von_Neuman 說得不錯,肯定是包的問題。
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.