在eclipse中加入XDoclet templates方便书写hibernate元数据

This document provides Eclipse and WebSphere Application Developer IDEs with XDoclet templates that can be used with Hibernate.

Template Name XDoclet Tag
hibarray @hibernate.array
hibbag @hibernate.bag
hibclass @hibernate.class
hibcolelm @hibernate.collection-element
hibcolidx @hibernate.collection-index
hibcolkey @hibernate.collection-key
hibcolmtm @hibernate.many-to-many
hibcolotm @hibernate.one-to-many
hibcomelm @hibernate.collection-composite-element
hibcomp @hibernate.component
hibdisc @hibernate.discriminator
hibid @hibernate.id
hiblist @hibernate.list
hibmap @hibernate.map
hibmto @hibernate.many-to-one
hiboto @hibernate.one-to-one
hibprimarr @hibernate.primitive-array
hibprop @hibernate.property
hibquery @hibernate.query
hibset @hibernate.set
hibsubc @hibernate.subclass
hibts @hibernate.timestamp
hibver @hibernate.version


步骤如下:

1.下载XDoclet templates for hibernate的xml文件  (请从附件中下载)

2.打开eclipse,找到Window/Preferences => Java/Editor/Templates => 点击Import 将XDoclet templates for hibernate的xml文件导入进去

3.假如你的中文windows切换输入法的快捷键是ctrl+space的话,因为这个与eclipse中的Content Assist快捷键相冲突了,因此你可以换一个输入法快捷键或者更换eclipse中的Content Assist快捷键,方法是:在eclipse中,进入到Window/Preferences => general => Keys找到Content Assist对其修改(注意要设置快捷键的有效范围是When:Editing Java Source)



hibarray back to top
@hibernate.array table="" cascade="save-update"

Parameter Description Mandatory
cascade Specifies which operations should be cascaded from the parent object to the associated object. Valid options are:any|none|save-update|delete|all-delete-orphan false
table The relationship collection table name (not used for one-to-many associations) false
schema Table schema to override the default schema declared on the root element false


hibbag back to top
@hibernate.bag table="" lazy="false" cascade="none" inverse="false"

Parameter Description Mandatory
table The relationship collection table name false
lazy Determines if this is a lazy loading relationship true false
cascade Specifies which operations should be cascaded from the parent object to the associated object. Valid options are:any|none|save-update|delete|all-delete-orphan false
inverse Indicates if this collection is the inverse collection of a bi-directional relationship false
schema Table schema to override the default schema declared on the root element false
order-by (optional, JDK1.4 only) specify a table column (or columns) that define the iteration order of the Map, Set or bag, together with an optional asc or desc false


hibclass back to top
@hibernate.class table="" discriminator-value=""

Parameter Description Mandatory
table The table name associated with this class false
discriminator-value (optional - defaults to the class name): A value that distiguishes individual subclasses, used for polymorphic behaviour. false
jcs-cache caching options : read-write false
mutable (optional, defaults to true): Specifies that instances of the class are (not) mutable. false
schema Table schema to override the default schema declared on the root element false
proxy (optional): Specifies an interface to use for lazy initializing proxies. You may specify the name of the class itself. false


hibcolem back to top
@hibernate.collection-element column="" type="" length=""

Parameter Description Mandatory
column The name of the mapped column false
type The Hibernate type false
length The length of the column false


hibcolidx back to top
@hibernate.collection-index column="" type="" length=""

Parameter Description Mandatory
column The name of the mapped column false
type The Hibernate type false
length The length of the column false


hibcolkey back to top
@hibernate.collection-key column="" generator-class="native"

Parameter Description Mandatory
column The name of the mapped column false
type The Hibernate type false
length The length of the field false
generator-class Names a Java class used to generate unique identifiers for instances of the persistent class. Valid values: increment true
generator-parameter-1 Parameter for key generator class false
generator-parameter-2 Parameter for key generator class false
generator-parameter-3 Parameter for key generator class false


hibcolmtm back to top
   @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}

Parameter Description Mandatory
class The name of the associated class false
column The name of the associated column false


hibcolotm back to top
   @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}

Parameter Description Mandatory
class Fully qualified name of the associated class false


hibcomelm back to top
@hibernate.collection-composite-element class=""

Parameter Description Mandatory
class The fully qualified name of the composite element class true


hibcomp back to top
@hibernate.component class="component_class_name"

Parameter Description Mandatory
class Fully qualified name of the associated class false


hibdisc back to top
@hibernate.discriminator column="subclass" type="character"

Parameter Description Mandatory
column The column used to distinguish the subclass false
type The Hibernate type false
length The length of the column false


hibid back to top
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}

Parameter Description Mandatory
column (optional - defaults to the property name): The name of the primary key column. false
type The Hibernate type false
length The length of the field false
unsaved-value unsaved-value (optional - defaults to null): 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.
values - any
false
generator-class Names a Java class used to generate unique identifiers for instances of the persistent class. Valid values: increment(info) false


hibmap back to top
@hibernate.map name="${enclosing_method}" table="relationship-table" lazy="false" cascade="none"

Parameter Description Mandatory
table (optional - defaults to property name) the name of the
collection table (not used for one-to-many associations)
false
lazy (optional - defaults to false) enable lazy initialization
(not used for arrays)
false
cascade (optional - defaults to none) enable operations to cascade to child entities false
schema (optional) the name of a table schema to override the schema declared on the root element false
sort (optional) specify a sorted collection with natural sort order, or a given comparator class false
order-by (optional, JDK1.4 only) specify a table column (or columns) that
define the iteration order of the Map, Set or bag, together with
an optional asc or desc
false
name The collection property name false


hibmto back to top
@hibernate.many-to-one column="${return_type}_ID" class="package.${return_type}"
*
* @return ${return_type}
*

Parameter Description Mandatory
name The name of the property. false
column (optional): The name of the column. false
class (optional - defaults to the property type determined by reflection): The name of the associated class. false
cascade (optional): Specifies which operations should be cascaded from the parent object to the associated object. false
outer-join (optional - defaults to auto): enables outer-join fetching for this association when hibernate.use_outer_join is set. false
update, insert (optional - defaults to true) specifies that the mapped columns should be included in SQL UPDATE and/or INSERT statements. Setting both to false allows a pure "derived" association whose value is initialized from some other property that maps to the same colum(s) or by a trigger or other application. false


hiboto back to top
hibernate.one-to-one cascade="none" class="" outer-join="auto"

Parameter Description Mandatory
class (optional - defaults to the property type determined by reflection): The name of the associated class. false
cascade (optional) specifies which operations should be cascaded from the parent object to the associated object. false
outer-join (optional - defaults to auto): Enable outer-join fetching for this association when hibernate. use_outer_join is set. false


hibprimarr back to top
@hibernate.primitive-array table="" cascade="none"

Parameter Description Mandatory
table The name of the table false
schema schema (optional) the name of a table schema to override the schema
declared on the root element
false
cascade (optional - defaults to none) enable operations to cascade to child entities
values - all
false


hibprop back to top
@hibernate.property name="${enclosing_method}" column="${enclosing_method}" type="${return_type}" not-null="false" unique="false"
*
* @return ${return_type}

Parameter Description Mandatory
name the name of the property, with an initial lowercase letter. false
column (optional - defaults to the property name): the name of the mapped database table column. false
type (optional): a name that indicates the Hibernate type. false
length The length of the mapped database table column. false
not-null If the column is not nullable false
unique If the column is unique false


hibquery back to top
@hibernate.query name="" query=""

Parameter Description Mandatory
name The name of the query false
query The HQL query statement false


hibset back to top
@hibernate.set name="${enclosing_method}" table="relationship_table"
* sort="comparator_class" inverse="true"
* cascade="save-update" lazy="true"

Parameter Description Mandatory
name the name of the property, with an initial lowercase letter. false
table The name of the association table false
sort The fully qualified comparator class (optional) false
inverse Indicates if this collection is the inverse collection of a bi-directional relationship false
cascade Specifies which operations should be cascaded from the parent object to the associated object. Valid options are:any|none|save-update|delete|all-delete-orphan false
lazy (optional - defaults to false) enable lazy initialization
(not used for arrays)
false
schema schema (optional) the name of a table schema to override the schema
declared on the root element
false


hibsubc back to top
@hibernate.subclass name="" discriminator-value=""

Parameter Description Mandatory
name The fully qualified class name of the subclass. false
discriminator-value (optional - defaults to the class name): A value that distiguishes individual subclasses. false
proxy (optional): Specifies a class or interface to use for lazy initializing proxies. false


hibts back to top
@hibernate.timestamp column="${enclosing_method}"
*
* @return ${return_type}

Parameter Description Mandatory
column The name of the column that contains the timestamp false


hibver back to top
@hibernate.version column="${enclosing_method}"
*
* @return ${return_type}

Parameter Description Mandatory
column The name of a column holding the version number. false

你可能感兴趣的:(eclipse,sql,Hibernate,windows,websphere)