`
yky1984
  • 浏览: 38717 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

在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完美支持XDoclet(新)

    3.展开Doclipse选择External files,然后在右边界面上选择插件目录,下面的列表中就会显示Hibernate3.xml 4.选中Hibernate3.xml,单击Apply. 测试 1.输入@,显示Hibernate标签,选择标签后,按提示键ctrl+space,...

    XDoclet2辅助开发hibernate3

    为了解决这个问题,XDoclet应运而生,特别是XDoclet2版本,它是一种自动化工具,能够根据Java源代码自动生成包括Hibernate映射文件在内的多种元数据文件。 XDoclet2是XDoclet的升级版,它基于JavaDoc注解,提供了一...

    为xdoclet添加hibernate智能提示

    因此,要实现对Hibernate的智能提示,我们需要在项目的XDoclet配置中指定Hibernate的元数据标签,比如@Entity、@Table、@Column等。 接下来,我们需要下载并安装支持Hibernate的XDoclet插件。这个插件可能包含在...

    XDoclet 与Hibernate 映射

    XDoclet 是一款强大的Java注解处理工具,它允许开发者在Java源代码中添加元数据,这些元数据可以用来自动生成各种配置文件,包括Hibernate的映射文件(hbm.xml)。这种方式极大地提高了开发效率,避免了手动创建和...

    用maven的xdoclet插件t生成hibernate配置文件

    在软件开发过程中,特别是涉及到数据库交互的应用程序中,Hibernate作为一款流行的Java持久层框架,被广泛应用于对象关系映射(ORM)。而在使用Hibernate时,自动生成配置文件能够极大地提高开发效率,减少手动编写...

    Hibernate 的Xdoclet模板

    4. **模板应用**:可能涉及到如何自定义Xdoclet模板以适应特定的项目需求,这通常涉及到修改如`templates-eclipse-tags.xml`这样的文件,该文件可能包含了Xdoclet在生成配置时所依据的模板定义。 5. **实例分析**:...

    Hibernate使用xdoclet生成映射文件和sql语句

    - 随着时间的推移,XDoclet逐渐被更现代的工具如Hibernate Tools(集成在Eclipse、IntelliJ等IDE中)所替代,这些工具提供了图形化界面,更直观地进行映射配置和SQL生成。 - 注解驱动的配置方式虽然简化了映射文件...

    xdoclet-src-1.2.1.zip eclipse

    4. **Eclipse插件**:虽然xdoclet-src-1.2.1.zip主要包含的是核心库和模块,但为了在Eclipse中使用XDoclet,还需要安装Eclipse插件。这通常涉及到将XDoclet集成到Eclipse的工作流中,比如通过配置Builder或使用特定...

    Ant结合Xdoclet 实例教程(之整合 Hibernate)

    它能从Java源代码的Javadoc注释中生成各种元数据,比如EJB组件的部署描述符、Hibernate映射文件等。这大大减少了手动编写这些配置文件的工作量,提高了开发效率。 整合Ant和Xdoclet,我们可以利用Xdoclet自动生成...

    xdoclet-1.2.1 ZIP包中包含了使用方法,供大家方便配置

    1. **使用详情.doc**:这是一个文档,详细介绍了如何在Eclipse项目中配置和使用XDoclet-1.2.1。通过阅读这个文档,开发者可以了解到安装步骤、配置过程以及如何在实际项目中应用XDoclet的各种功能。对于初学者来说,...

    struts+hibernate+spring+xdoclet+ant+log4j

    Struts、Hibernate、Spring、XDoclet、Ant和Log4j是Java开发中常见的六个重要组件,它们在企业级应用开发中发挥着关键作用。这些技术的整合为开发者提供了高效、灵活和可维护的解决方案。 **Struts** 是一个基于MVC...

    让Eclipse支持XDoclet标签

    通过导入此文件模板,让Eclipse可以支持标签提示, 导入步骤:Eclipse -> Window -> Preferences -> Java -> Editor -> Templates -> Import -> templates.xml

    用eclipse+xdoclet+axis开发WebService.pdf

    2. **配置XDoclet:** 在Eclipse的项目属性中找到XDoclet配置,设置ejbdoclet和fileset等参数,使得在编译过程中XDoclet可以根据源代码中的注释自动生成WSDL文件和部署描述文件。 3. **运行XDoclet:** 在配置好...

    XDOCLET的使用例子

    Ant的任务执行机制使得XDoclet的运行自动化,方便在大型项目中集成到持续集成流程中。 **Java工具** XDoclet是Java开发者的一个重要辅助工具,它与Java语言的紧密结合体现在Javadoc注释上。通过在Java类中添加特殊...

    xdoclet 生成hbm文件

    为了解决这个问题,XDoclet应运而生,它是一种强大的Java文档注解处理器,能够自动生成包括Hibernate映射文件在内的各种元数据文件。本文将详细介绍如何在MyEclipse环境中利用XDoclet生成HBM文件。 首先,确保你的...

    xdoclet_lib_1.2.3

    3. **提高可维护性**:所有与持久化相关的元数据都集中在源代码中,方便查看和理解,有利于项目的长期维护。 然而,需要注意的是,随着Java世界的发展,诸如Hibernate 3.0以后的版本和JPA的出现,XDoclet的角色逐渐...

Global site tag (gtag.js) - Google Analytics