Hibernate實體映射模板

來源:互聯網
上載者:User

標籤:java   hibernate   實體映射   模板   

Hibernate實體映射模板

1,寫注釋     ?格式為:?屬性,表達的是本對象與?的?關係。     ?例:“department屬性,本對象與Department的多對一”2,拷模板:

多對一

<many-to-one name=“” class=“” column=“”/>

一對多

(Set)

<set name="">

        <key column=""></key>

        <one-to-many class=""/>

</set>

多對多

(Set)

<set name="" table="">

        <key column=""></key>

        <many-to-many class="" column=""/>

</set>



3,填空:      ?name屬性:屬性名稱(注釋中的第1問號)      ?class屬性:關聯的實體類型(注釋中的第2個問號)      ?column屬性:       ?<many-to-onecolumn="..">:一般可以寫成屬性名稱加Id尾碼,如屬性為department,則column值寫成          departmentId。      ?一對多中的<keycolumn="..">:從關聯的對方(對方是多對一)映射中把column值拷貝過來。      ?多對多中的<keycolumn=“..”>:一般可以寫成本對象的名加Id尾碼,如本對象名為User,則寫為userId。     ?多對多中的<many-to-manycolumn=“..”>:一般可以寫為關聯對象的名稱加Id尾碼。


增刪改查所用的6個Action方法的模板

/** 列表 */

public String list()throws Exception {return"list"; }

/** 刪除 */

public String delete()throws Exception {return"toList"; }

/** 添加頁面 */

public StringaddUI()throws Exception {return"saveUI"; }

/** 添加 */

public String add()throws Exception {return"toList"; }

/** 修改頁面 */

public StringeditUI()throws Exception {return"saveUI"; }

/** 修改 */

public String edit()throws Exception {return"toList"; }


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.