西部村里人

          常用鏈接

          統(tǒng)計

          其它BLOG

          最新評論

          Hibernate對象關(guān)聯(lián)--UML基礎(chǔ)知識、XDoclet---- 5 XDoclet Template In Eclipse

              在隨筆中發(fā)了一篇XDoclet Template In Eclipse的內(nèi)容,在實際使用過程中,我又按照個人習(xí)慣,進(jìn)行了分類編輯,以便于更快捷的使用。
           
          <?xml version="1.0" encoding="UTF-8"?>
          <templates><template name="@hib-blob-byte" description="blob to byte" context="javadoc" enabled="true" deleted="false" autoinsert="true">@hibernate.property column="${enclosing_method}"  type="org.springframework.orm.hibernate3.support.BlobByteArrayType" lazy="true"&#13;     &#13;     &#13;     </template><template name="@hib-class" description="@hibernate.class" context="javadoc" enabled="true" deleted="false" autoinsert="true">@hibernate.class table="${enclosing_type}" dynamic-update="true"</template><template name="@hib-class-disc" description="@hibernate.discriminator" context="javadoc" enabled="true" deleted="false" autoinsert="true">@hibernate.discriminator column="type" type="character" not-null="true" force="false"</template><template name="@hib-class-join" description="hibernate join subclass" context="javadoc" enabled="true" deleted="false" autoinsert="true">@hibernate.joined-subclass table="${primary_type_name}" lazy="true" dynamic-update="true"&#13;
          *@hibernate.joined-subclass-key column="${primary_type_name}Guid"&#13;*&#13;*請修改子類的表名,對應(yīng)表的主鍵,該主鍵不需要定義在類的屬性中,它對應(yīng)父類的主鍵&#13;
           </template><template name="@hib-class-sub" description="@hibernate.subclass" context="javadoc" enabled="true" deleted="false" autoinsert="true">@hibernate.subclass name="${file}" discriminator-value=""</template><template name="@hib-id-assign" description="id is assign" context="javadoc" enabled="true" deleted="false" autoinsert="true">@hibernate.id generator-class="assigned" length="20" column="請修改"&#13;</template><template name="@hib-id-guid" description="id is guid" context="javadoc" enabled="true" deleted="false" autoinsert="true">@hibernate.id generator-class="uuid" type="java.lang.String" &#13;
              * @hibernate.column name="guid" sql-type="VARCHAR(38)" not-null="true"&#13;    *&#13;
              * 請修改name of column的值</template><template name="@hib-rel-many-to-many-list" description="many to many list" context="javadoc" enabled="true" deleted="false" autoinsert="true">@hibernate.list name="方法名(無Get)" inverse="true" cascade="save-update"&#13;
               *                 lazy="true"&#13;
               * @hibernate.collection-key column="外鍵"&#13;
               * @hibernate.collection-index column="tabIndex" type="int"&#13;
               * @hibernate.collection-one-to-many class="關(guān)聯(lián)的類"&#13;
               * &#13;
               * 請修改外鍵,并且指定完整的關(guān)聯(lián)類的類名(包+類名)</template><template name="@hib-rel-many-to-many-set" description="many 2 many set" context="javadoc" enabled="true" deleted="false" autoinsert="true">@hibernate.set name="${enclosing_method}" table="關(guān)聯(lián)表" cascade="save-update" inverse="true" lazy="true"&#13;     * @hibernate.collection-key column="自己的主鍵"&#13;     * @hibernate.collection-many-to-many class="關(guān)聯(lián)類" column="關(guān)聯(lián)類的主鍵"&#13;     *&#13;     * 兩個類的主鍵構(gòu)成關(guān)聯(lián)表的屬性,關(guān)聯(lián)類請寫完整的類名&#13;     * 多對多時,只能指定一個多的方向斷子為true,即inverse="true"&#13;     * 多對多時,無法指定index順序,因為你無法確定從兩個方向看上去都具有順序,所以使用List不可靠&#13;</template><template name="@hib-rel-many-to-one" description="@hibernate.many-to-one" context="javadoc" enabled="true" deleted="false" autoinsert="true">@hibernate.many-to-one column="${enclosing_method}_ID" class="${return_type}" cascade="none" outer-join="auto" not-null="false" lazy="true"
               *&#13;     * 請給class指定完整的包名+類名
               * @return ${return_type}
               *</template><template name="@hib-rel-one-to-many-list" description="@hibernate.one-to-many relationship" context="javadoc" enabled="true" deleted="false" autoinsert="true">@hibernate.list name="${enclosing_method}" inverse="true"    cascade="save-update" lazy="true"&#13;     * @hibernate.collection-key column="外鍵"&#13;     * @hibernate.collection-index column="TABINDEX" type="int"&#13;     * @hibernate.collection-one-to-many class="關(guān)聯(lián)的類"&#13;     *&#13;     * 請修改外鍵,并且指定完整的關(guān)聯(lián)類的類名(包+類名)&#13;</template><template name="@hib-rel-one-to-many-set" description="one 2 many set" context="javadoc" enabled="true" deleted="false" autoinsert="true">@hibernate.set name="${enclosing_method}" inverse="true"    cascade="save-update" lazy="true"&#13;
               * @hibernate.collection-key column="外鍵"&#13;
               * @hibernate.collection-one-to-many class="關(guān)聯(lián)的類"&#13;
               *&#13;
               * 請修改外鍵,并且指定完整的關(guān)聯(lián)類的類名(包+類名)&#13;
          </template><template name="@hib-rel-parent-child-list" description="one to mang [construct a tree]" context="javadoc" enabled="true" deleted="false" autoinsert="true">@hibernate.list lazy="true" inverse="true" cascade="all"&#13;
               * @hibernate.collection-key column="parentGuid"&#13;
               * @hibernate.collection-index column="tabIndex"&#13;
               * @hibernate.collection-one-to-many class="${enclosing_package}.${primary_type_name}"&#13;
               *&#13;
               * 請修改collection-key,它是many方的外鍵&#13;
               * tabIndex可以修改,也可以不修改,而且類中不必要一定有這個屬性存在,因為它是Hib在操作List時需要的一個屬性,只需數(shù)據(jù)庫中定義了即可。&#13;
          &#13;
          </template><template name="@hib-string-clob" description="hibernate string to clob" context="javadoc" enabled="true" deleted="false" autoinsert="true">@hibernate.property name="${enclosing_method}" column="ORG_Description" type="org.springframework.orm.hibernate3.support.ClobStringType" not-null="false" unique="false" length="4000"&#13;</template></templates>

               如何倒入?yún)⒖茧S筆。
               代碼實例:
              /**
               * @hibernate.id generator-class="uuid" type="java.lang.String"
               *               name="guid" column="A_GUID" length="38"
               *
               */
              public java.lang.String getGuid() {
                  return orgGuid;
              }

               private Set childDepartment;

              /**
               * @hibernate.set lazy="false" cascade="all" lazy="true"
               * @hibernate.collection-key column="Superior_GUID"
               * @hibernate.collection-one-to-many class="model.Department"
               *
               * @return Set
               */
              public Set getChildDepartment() {
                  return childDepartment;
              }

              public void setChildDepartment(Set childDepartment) {
                  this.childDepartment = childDepartment;
              }
             
              private Set roles;
              /**
               * many to may
               *
               * @hibernate.set name="roles" table="ORG_DEPT_REF_ROLE"
               *                 cascade="save-update" inverse="true" lazy="true"
               * @hibernate.collection-key column="DEPT_GUID"
               * @hibernate.collection-many-to-many class="model.Role"
               *                                    column="ROLE_GUID"
               * @return Set
               */
              public Set getRoles() {
                  return roles;
              }

              public void setRoles(Set roles) {
                  this.roles = roles;
              }
             
              private List positions;

              /**
               *
               * @hibernate.list name="positions" inverse="true" cascade="save-update"
               *                 lazy="true"
               * @hibernate.collection-key column="DEPT_GUID"
               * @hibernate.collection-index column="POSITION_TABINDEX" type="int"
               * @hibernate.collection-one-to-many class="model.Position"
               *
               * 請修改外鍵,并且指定完整的關(guān)聯(lián)類的類名(包+類名)
               */
              public List getPositions() {
                  return positions;
              }

              public void setPositions(List positions) {
                  this.positions = positions;
              }

          posted on 2006-03-12 15:13 西部村里人 閱讀(586) 評論(0)  編輯  收藏 所屬分類: Hibernate

          主站蜘蛛池模板: 苍山县| 靖江市| 廊坊市| 星座| 嫩江县| 泰安市| 三河市| 黑水县| 金山区| 西藏| 昭通市| 高青县| 玉田县| 陆河县| 遵化市| 缙云县| 宜君县| 仙居县| 万山特区| 吉林省| 益阳市| 马关县| 什邡市| 百色市| 祁阳县| 天全县| 石棉县| 双峰县| 南召县| 兴安县| 安溪县| 乌海市| 科技| 兴海县| 绥阳县| 同江市| 辽阳市| 长寿区| 临清市| 灵璧县| 措勤县|