`
爱像天空
  • 浏览: 197775 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

基本O/R映射(一)--Hibernate快速参考

    博客分类:
  • SSH
阅读更多
hibernate-3.2/doc/reference/en/html/mapping.html#mapping-declaration-properties一.Class元素,声明类名与表名加粗部分为最基本的元素<class
        name="ClassName"                              (1)
        table="tableName"                             (2)
        discriminator-value="discriminator_value"     (3)
        mutable="true|false"                          (4)
        schema="owner"                                (5)
        catalog="catalog"                             (6)
        proxy="ProxyInterface"                        (7)
        dynamic-update="true|false"                   (8)
        dynamic-insert="true|false"                   (9)
        select-before-update="true|false"             (10)
        polymorphism="implicit|explicit"              (11)
        where="arbitrary sql where condition"         (12)
        persister="PersisterClass"                    (13)
        batch-size="N"                                (14)
        optimistic-lock="none|version|dirty|all"      (15)
        lazy="true|false"                             (16)
        entity-name="EntityName"                      (17)
        check="arbitrary sql check condition"         (18)
        rowid="rowid"                                 (19)
        subselect="SQL expression"                    (20)
        abstract="true|false"                         (21)
        node="element-name"
/>以下加粗部分为常用属性 (1) name (optional): The fully qualified Java class name of the persistent class (or interface). If this attribute is missing, it is assumed that the mapping is for a non-POJO entity.  (2) table (optional - defaults to the unqualified class name): The name of its database table.  (3) discriminator-value (optional - defaults to the class name): A value that distiguishes individual subclasses, used for polymorphic behaviour. Acceptable values include null and not null.  (4) mutable (optional, defaults to true): Specifies that instances of the class are (not) mutable.  (5) schema (optional): Override the schema name specified by the root <hibernate-mapping> element.  (6) catalog (optional): Override the catalog name specified by the root <hibernate-mapping> element.  (7) proxy (optional): Specifies an interface to use for lazy initializing proxies. You may specify the name of the class itself.  (8) dynamic-update (optional, defaults to false): Specifies that UPDATE SQL should be generated at runtime and contain only those columns whose values have changed.  (9) dynamic-insert (optional, defaults to false): Specifies that INSERT SQL should be generated at runtime and contain only the columns whose values are not null.  (10) select-before-update (optional, defaults to false): Specifies that Hibernate should never perform an SQL UPDATE unless it is certain that an object is actually modified. In certain cases (actually, only when a transient object has been associated with a new session using update()), this means that Hibernate will perform an extra SQL SELECT to determine if an UPDATE is actually required.  (11) polymorphism (optional, defaults to implicit): Determines whether implicit or explicit query polymorphism is used.  (12) where (optional) specify an arbitrary SQL WHERE condition to be used when retrieving objects of this class  (13) persister (optional): Specifies a custom ClassPersister.  (14) batch-size (optional, defaults to 1) specify a "batch size" for fetching instances of this class by identifier.  (15) optimistic-lock (optional, defaults to version): Determines the optimistic locking strategy.  (16) lazy (optional): Lazy fetching may be completely disabled by setting lazy="false".  (17) entity-name (optional, defaults to the class name): Hibernate3 allows a class to be mapped multiple times (to different tables, potentially), and allows entity mappings that are represented by Maps or XML at the Java level. In these cases, you should provide an explicit arbitrary name for the entity. See Section 4.4, “Dynamic models” and Chapter 18, XML Mapping for more information.  (18) check (optional): A SQL expression used to generate a multi-row check constraint for automatic schema generation.  (19) rowid (optional): Hibernate can use so called ROWIDs on databases which support. E.g. on Oracle, Hibernate can use the rowid extra column for fast updates if you set this option to rowid. A ROWID is an implementation detail and represents the physical location of a stored tuple.  (20) subselect (optional): Maps an immutable and read-only entity to a database subselect. Useful if you want to have a view instead of a base table, but don't. See below for more information.  (21) abstract (optional): Used to mark abstract superclasses in <union-subclass> hierarchies.  二.ID元素<id        name="propertyName"                                          (1)        type="typename"                                              (2)        column="column_name"                                         (3)        unsaved-value="null|any|none|undefined|id_value"             (4)        access="field|property|ClassName">                           (5)        node="element-name|@attribute-name|element/@attribute|."        <generator class="generatorClass"/></id>(1) name (optional): The name of the identifier property.  (2) type (optional): A name that indicates the Hibernate type.  (3) column (optional - defaults to the property name): The name of the primary key column.  (4) unsaved-value (optional - defaults to a "sensible" value): An identifier property value that indicates that an instance is newly instantiated (unsaved), distinguishing it from detached instances that were saved or loaded in a previous session.  (5) access (optional - defaults to property): The strategy Hibernate should use for accessing the property value. 三.Generator子元素<id name="id" type="long" column="cat_id">        <generator class="org.hibernate.id.TableHiLoGenerator">                <param name="table">uid_table</param>                <param name="column">next_hi_value_column</param>        </generator></id>内置标识符生成器increment:适合于代理主键.由Hibernate自动以递增方式生成标识符,每次增量为一identity:适合于代理主键.由底层数据库
分享到:
评论

相关推荐

    深入浅出Hibernate中文版 part1

    4.3 Hibernate O/R映射 4.4 数据关联 4.5 Hibernate数据检索 4.6 HQL实用技术 4.7 自定义持久化实现 第5章 Hibernate高级特性 5.1 Hibernate持久化实现 5.2 Hibernate回调与拦截机制 5.3 Hibernate实用技术 ...

    深入浅出Hibernate中文版 part2

    4.3 Hibernate O/R映射 4.4 数据关联 4.5 Hibernate数据检索 4.6 HQL实用技术 4.7 自定义持久化实现 第5章 Hibernate高级特性 5.1 Hibernate持久化实现 5.2 Hibernate回调与拦截机制 5.3 Hibernate实用技术 ...

    深入浅出Hibernate(PDF)第一部分

    直至Hibernate实战,重点讲述了Hibernate的基础语法、基础配置、O/R映射、数据关联、数据检索、HQL实用技术、自定义持久化实现、Hibernate回调与拦截、Hibernate分页等实用技术,Hibernate实战部分则用一个真实论坛...

    深入浅出Hibernate

    在附录中讲述了Hibernate常用的映射配置,Hibernate工具、XDoclet模板配置以及Hibernate的益友iBatis用法,还以卡片的形式列出了本书中所用的工具及软件,附录最后一部分是“快速启动代码”,供读者对比与参考,...

    深入浅出Hibernate.pdf

    直至Hibernate实战,重点讲述了Hibernate的基础语法、基础配置、O/R映射、数据关联、数据检索、HQL实用技术、自定义持久化实现、Hibernate回调与拦截、Hibernate分页等实用技术,Hibernate实战部分则用一个真实论坛...

    中文 深入浅出Hibernate

    直至Hibernate实战,重点讲述了Hibernate的基础语法、基础配置、O/R映射、数据关联、数据检索、HQL实用技术、自定义持久化实现、Hibernate回调与拦截、Hibernate分页等实用技术,Hibernate实战部分则用一个真实论坛...

    深入浅出Hibernate(PDF)第二部分

    直至Hibernate实战,重点讲述了Hibernate的基础语法、基础配置、O/R映射、数据关联、数据检索、HQL实用技术、自定义持久化实现、Hibernate回调与拦截、Hibernate分页等实用技术,Hibernate实战部分则用一个真实论坛...

    深入浅出hibernate(PDF)第三部分

    直至Hibernate实战,重点讲述了Hibernate的基础语法、基础配置、O/R映射、数据关联、数据检索、HQL实用技术、自定义持久化实现、Hibernate回调与拦截、Hibernate分页等实用技术,Hibernate实战部分则用一个真实论坛...

    \深入浅出Hibernate

    直至Hibernate实战,重点讲述了Hibernate的基础语法、基础配置、O/R映射、数据关联、数据检索、HQL实用技术、自定义持久化实现、Hibernate回调与拦截、Hibernate分页等实用技术,Hibernate实战部分则用一个真实论坛...

    深入浅出Hibernate2

    直至Hibernate实战,重点讲述了Hibernate的基础语法、基础配置、O/R映射、数据关联、数据检索、HQL实用技术、自定义持久化实现、Hibernate回调与拦截、Hibernate分页等实用技术,Hibernate实战部分则用一个真实论坛...

    Hibernate框架参考文档

    5. 对象/关系数据库映射基础(Basic O/R Mapping); 6. 集合类(Collections)映射; 7. 关联关系映射; 8. 组件(Component)映射; 9. 继承映射(Inheritance Mappings); 10. 与对象共事; 11. 事务和并发; 12. 拦截器与...

    《深入浅出Hibernate》1

    直至Hibernate实战,重点讲述了Hibernate的基础语法、基础配置、O/R映射、数据关联、数据检索、HQL实用技术、自定义持久化实现、Hibernate回调与拦截、Hibernate分页等实用技术,Hibernate实战部分则用一个真实论坛...

    最全Hibernate 参考文档

    5. 对象/关系数据库映射基础(Basic O/R Mapping) 5.1. 映射定义(Mapping declaration) 5.1.1. Doctype 5.1.2. hibernate-mapping 5.1.3. class 5.1.4. id 5.1.4.1. Generator 5.1.4.2. 高/低位算法(Hi/Lo ...

    hibernate中文参考文档

    5、O/R Mapping基础 6、集合类映射 7、组件映射 8、继承映射 9、操作持久化数据 10、事务和并行 11、Hibernate查询语言 12、条件查询 13、原生SQL查询 14、性能提升 15、工具箱指南 16、示例:父子关系 17、示例:...

    HibernateAPI中文版.chm

    Hibernate参考文档 3.2 -------------------------------------------------------------------------------- 目录 前言 1. 翻译说明 2. 版权声明 1. Hibernate入门 1.1. 前言 1.2. 第一部分 - 第一个...

    hibernate3.2中文文档(chm格式)

    Hibernate参考文档 3.2 -------------------------------------------------------------------------------- 目录 前言 1. 翻译说明 2. 版权声明 1. Hibernate入门 1.1. 前言 1.2. 第一部分 - 第一个...

    夏昕.深入浅出Hibernate

    在附录中讲述了Hibernate常用的映射配置,Hibernate工具、XDoclet模板配置以及Hibernate的益友iBatis用法,还以卡片的形式列出了本书中所用的工具及软件,附录最后一部分是“快速启动代码”,供读者对比与参考,也给...

    hibernate 体系结构与配置 参考文档(html)

    5. 对象/关系数据库映射基础(Basic O/R Mapping) 5.1. 映射定义(Mapping declaration) 5.1.1. Doctype 5.1.2. hibernate-mapping 5.1.3. class 5.1.4. id 5.1.4.1. Generator 5.1.4.2. 高/低位算法(Hi/Lo ...

Global site tag (gtag.js) - Google Analytics