java學習

          java學習

           

          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>
          在數據庫中生成5個表

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


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


          網站導航:
           

          導航

          統計

          常用鏈接

          留言簿

          隨筆檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 乐东| 马边| 错那县| 绥棱县| 精河县| 海南省| 麻阳| 沁阳市| 宜州市| 唐海县| 赣榆县| 临沧市| 环江| 福海县| 清原| 唐海县| 子长县| 黄大仙区| 阜平县| 龙南县| 晋中市| 霸州市| 凤庆县| 淅川县| 津南区| 搜索| 梧州市| 淮安市| 惠水县| 建湖县| 延安市| 崇义县| 东源县| 南通市| 安阳市| 海口市| 曲靖市| 清涧县| 高平市| 汨罗市| 浦北县|