西部村里人

          常用鏈接

          統計

          其它BLOG

          最新評論

          Hibernate對象關聯--UML基礎知識、XDoclet---- 5 XDoclet Template In Eclipse

              在隨筆中發了一篇XDoclet Template In Eclipse的內容,在實際使用過程中,我又按照個人習慣,進行了分類編輯,以便于更快捷的使用。
           
          <?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;*請修改子類的表名,對應表的主鍵,該主鍵不需要定義在類的屬性中,它對應父類的主鍵&#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="關聯的類"&#13;
               * &#13;
               * 請修改外鍵,并且指定完整的關聯類的類名(包+類名)</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="關聯表" cascade="save-update" inverse="true" lazy="true"&#13;     * @hibernate.collection-key column="自己的主鍵"&#13;     * @hibernate.collection-many-to-many class="關聯類" column="關聯類的主鍵"&#13;     *&#13;     * 兩個類的主鍵構成關聯表的屬性,關聯類請寫完整的類名&#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="關聯的類"&#13;     *&#13;     * 請修改外鍵,并且指定完整的關聯類的類名(包+類名)&#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="關聯的類"&#13;
               *&#13;
               * 請修改外鍵,并且指定完整的關聯類的類名(包+類名)&#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時需要的一個屬性,只需數據庫中定義了即可。&#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>

               如何倒入參考隨筆。
               代碼實例:
              /**
               * @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"
               *
               * 請修改外鍵,并且指定完整的關聯類的類名(包+類名)
               */
              public List getPositions() {
                  return positions;
              }

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

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

          主站蜘蛛池模板: 馆陶县| 琼结县| 阳曲县| 潼南县| 城固县| 沾化县| 米泉市| 益阳市| 富蕴县| 呼和浩特市| 句容市| 宿州市| 望城县| 枣庄市| 铜鼓县| 威信县| 裕民县| 区。| 哈巴河县| 富平县| 建水县| 日照市| 阿城市| 高碑店市| 塔城市| 乐至县| 社旗县| 五常市| 荔浦县| 讷河市| 耒阳市| 台北县| 芜湖市| 安龙县| 长阳| 东城区| 四平市| 遂川县| 休宁县| 九江县| 辽宁省|