java學(xué)習(xí)

          java學(xué)習(xí)

           

          hibernate 中集合映射成表

          實體類是:

          public class CollectionMapping {
           
           private int id;
           
           private String name;
           
           private Set setValue;
           
           private List listValue;
           
           private String[] arrayValue;
           
           private Map mapValue;

           public int getId() {
            return id;
           }

           public void setId(int id) {
            this.id = id;
           }

           public String getName() {
            return name;
           }

           public void setName(String name) {
            this.name = name;
           }

           public Set getSetValue() {
            return setValue;
           }

           public void setSetValue(Set setValue) {
            this.setValue = setValue;
           }

           public List getListValue() {
            return listValue;
           }

           public void setListValue(List listValue) {
            this.listValue = listValue;
           }

           public String[] getArrayValue() {
            return arrayValue;
           }

           public void setArrayValue(String[] arrayValue) {
            this.arrayValue = arrayValue;
           }

           public Map getMapValue() {
            return mapValue;
           }

           public void setMapValue(Map mapValue) {
            this.mapValue = mapValue;
           }
          }

          在CollectionMapping.hbm.xml文件中:
          <hibernate-mapping>
           <class name="CollectionMapping" table="t_CollectionMapping">
            <id name="id">
             <generator class="native"/>
            </id>
            <property name="name"/>
            <set name="setValue" table="t_set_value">
             <key column="set_id"/>
             <element type="string" column="set_value"/>
            </set>
            <list name="listValue" table="t_list_value">
             <key column="list_id"/>
             <list-index column="list_index"/>
             <element type="string" column="list_value"/>
            </list>
            <array name="arrayValue" table="t_array_value">
             <key column="array_id"/>
             <list-index column="array_index"/>
             <element type="string" column="array_value"/>
            </array>
            <map name="mapValue" table="t_map_value">
             <key column="map_id"/>
             <map-key type="string" column="map_key"/>
             <element type="string" column="map_value"/>
            </map>
           </class>
          </hibernate-mapping>
          在數(shù)據(jù)庫中生成5個表

          posted on 2013-05-06 22:22 楊軍威 閱讀(187) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           

          導(dǎo)航

          統(tǒng)計

          常用鏈接

          留言簿

          隨筆檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 建湖县| 定陶县| 呼伦贝尔市| 吴江市| 奉化市| 肇州县| 仁布县| 镇沅| 建德市| 江西省| 精河县| 胶州市| 辽阳市| 富顺县| 崇信县| 盐源县| 新龙县| 绥宁县| 华宁县| 丽江市| 伊川县| 汝城县| 建瓯市| 绥化市| 丘北县| 龙南县| 曲阳县| 托里县| 桃源县| 富锦市| 阆中市| 车险| 商洛市| 普陀区| 上林县| 额敏县| 顺义区| 丰原市| 北安市| 建德市| 平和县|