步骤如下:
1.将下面代码保存为xdoclet templates for hibernate.xml文件
2.打开eclipse,找到Window/Preferences => Java/Editor/Templates => 点击Import 将xdoclet templates for hibernate的xml文件导入进去
<?xml version="1.0" encoding="UTF-8"?>
<templates><template name="@hibarray" description="hibernate.array" context="javadoc" enabled="true">@hibernate.array table="" cascade="save-update"</template>
<template name="@hibbag" description="hibernate.bag" context="javadoc" enabled="true">@hibernate.bag table="" lazy="false" cascade="none" inverse="false"</template>
<template name="@hibclass" description="hibernate.class" context="javadoc" enabled="true">@hibernate.class table="${enclosing_type}"</template>
<template name="@hibcolelm" description="hibernate.collection-element" context="javadoc" enabled="true">@hibernate.collection-element column="" type="" length=""</template>
<template name="@hibcolidx" description="hibernate.collection-index" context="javadoc" enabled="true">@hibernate.collection-index column="" type="" length=""</template>
<template name="@hibcolkey" description="hibernate.collection-key" context="javadoc" enabled="true">@hibernate.collection-key column="" generator-class="native"</template>
<template name="@hibcolmtm" description="hibernate.many-to-many" context="javadoc" enabled="true">@hibernate.set name="${enclosing_method}" table="link_table_name_here" cascade="save-update" inverse="true|false" lazy="true"
* @hibernate.collection-key column="${enclosing_type}_ID"
* @hibernate.collection-many-to-many class="relationship_class_the_set_contains" column="relationship_foreign_key"
* @return ${return_type}</template>
<template name="@hibcolotm" description="hibernate.one-to-many relationship" context="javadoc" enabled="true">@hibernate.set name="${enclosing_method}" table="relationship_table"
* sort="comparator_class" inverse="true|false"
* cascade="save-update" lazy="true"
* @hibernate.collection-key column="${enclosing_type}_ID"
* @hibernate.collection-one-to-many class="relationship_class"
*
* @return ${return_type}</template>
<template name="@hibcomelm" description="hibernate.collection-composite-element" context="javadoc" enabled="true">@hibernate.collection-composite-element class=""</template>
<template name="@hibcomp" description="hibernate.component" context="javadoc" enabled="true">@hibernate.component class="component_class_name"</template>
<template name="@hibdisc" description="hibernate.discriminator" context="javadoc" enabled="true">@hibernate.discriminator column="subclass" type="character"</template>
<template name="@hibid" description="hibernate.id" context="javadoc" enabled="true">Note: unsaved-value An identifier property value that indicates that an instance
* is newly instantiated (unsaved), distinguishing it from transient instances that
* were saved or loaded in a previous session. If not specified you will get an exception like this:
* another object associated with the session has the same identifier
*
* @hibernate.id generator-class="" type="${return_type}" column="${enclosing_type}_ID"
* unsaved-value="null" length=""
* @return ${return_type}</template>
<template name="@hiblist" description="hibernate.list" context="javadoc" enabled="true">@hibernate.list table="relationship-table" lazy="false" cascade="none"</template>
<template name="@hibmap" description="hibernate.map" context="javadoc" enabled="true">@hibernate.map name="${enclosing_method}" table="relationship-table" lazy="false" cascade="none"</template>
<template name="@hibmto" description="hibernate.many-to-one" context="javadoc" enabled="true">@hibernate.many-to-one column="${return_type}_ID" class="package.${return_type}"
*
* @return ${return_type}
*</template>
<template name="@hiboto" description="hibernate.one-to-one" context="javadoc" enabled="true">hibernate.one-to-one cascade="none" class="" outer-join="auto"</template>
<template name="@hibprimarr" description="hibernate.primitive-array" context="javadoc" enabled="true">@hibernate.primitive-array table="" cascade="none"</template>
<template name="@hibprop" description="hibernate.property" context="javadoc" enabled="true">@hibernate.property name="${enclosing_method}" column="${enclosing_method}" type="${return_type}" not-null="false" unique="false"
*
* @return ${return_type}</template>
<template name="@hibquery" description="hibernate.query" context="javadoc" enabled="true">@hibernate.query name="" query=""</template>
<template name="@hibset" description="hibernate.set" context="javadoc" enabled="true">@hibernate.set name="${enclosing_method}" table="relationship_table"
* sort="comparator_class" inverse="true"
* cascade="save-update" lazy="true"</template>
<template name="@hibsubc" description="hibernate.subclass" context="javadoc" enabled="true">@hibernate.subclass name="" discriminator-value=""</template>
<template name="@hibts" description="hibernate.timestamp" context="javadoc" enabled="true">@hibernate.timestamp column="${enclosing_method}"
*
* @return ${return_type}</template>
<template name="@hibver" description="hibernate.version" context="javadoc" enabled="true">@hibernate.version column="${enclosing_method}"
*
* @return ${return_type}</template>
</templates>