hibernate_reference中文文档.pdf

时间:2014-01-19 12:50:04
【文件属性】:

文件名称:hibernate_reference中文文档.pdf

文件大小:1.52MB

文件格式:PDF

更新时间:2014-01-19 12:50:04

hibernate_reference中文文档.pdf

前言 ............................................................................ xi 1. 教程 ......................................................................... 1 1.1. 第一部分 - 第一个 Hibernate 应用程序 ................................. 1 1.1.1. 设置 ............................................................ 1 1.1.2. 第一个 class ................................................... 3 1.1.3. 映射文件 ........................................................ 4 1.1.4. Hibernate 配置 .................................................. 7 1.1.5. 用 Maven 构建 .................................................. 9 1.1.6. 启动和辅助类 .................................................... 9 1.1.7. 加载并存储对象 ................................................. 10 1.2. 第二部分 - 关联映射 ................................................. 13 1.2.1. 映射 Person 类 ................................................ 13 1.2.2. 单向 Set-based 的关联 ......................................... 14 1.2.3. 使关联工作 ..................................................... 15 1.2.4. 值类型的集合 ................................................... 17 1.2.5. 双向关联 ....................................................... 18 1.2.6. 使双向连起来 ................................................... 19 1.3. 第三部分 - EventManager web 应用程序 ................................. 20 1.3.1. 编写基本的 servlet ............................................. 20 1.3.2. 处理与渲染 ..................................................... 21 1.3.3. 部署与测试 ..................................................... 24 1.4. 总结 ................................................................. 25 2. 体系结构(Architecture) ..................................................... 27 2.1. 概况(Overview) ...................................................... 27 2.2. 实例状态 .............................................................. 29 2.3. JMX 整合 ............................................................. 30 2.4. 对 JCA 的支持 ........................................................ 30 2.5. 上下文相关的会话(Contextual Session) ................................ 30 3. 配置 ........................................................................ 33 3.1. 可编程的配置方式 ...................................................... 33 3.2. 获得 SessionFactory .................................................. 34 3.3. JDBC 连接 ............................................................ 34 3.4. 可选的配置属性 ........................................................ 36 3.4.1. SQL 方言 ...................................................... 42 3.4.2. 外连接抓取(Outer Join Fetching) .............................. 43 3.4.3. 二进制流(Binary Streams) ..................................... 43 3.4.4. 二级缓存与查询缓存 ............................................. 43 3.4.5. 查询语言中的替换 ............................................... 43 3.4.6. Hibernate 的统计(statistics)机制 ............................. 43 3.5. 日志 ................................................................. 44 3.6. 实现 NamingStrategy .................................................. 44 3.7. XML 配置文件 ......................................................... 45 3.8. J2EE 应用程序服务器的集成 ............................................. 46 3.8.1. 事务策略配置 ................................................... 46HIBERNATE - Relational Persis... iv 3.8.2. JNDI 绑定的 SessionFactory ..................................... 47 3.8.3. 在 JTA 环境下使用 Current Session context(当前 session 上下文) 管理 .................................................................. 48 3.8.4. JMX 部署 ...................................................... 48 4. 持久化类(Persistent Classes) .............................................. 51 4.1. 一个简单的 POJO 例子 ................................................. 51 4.1.1. 实现一个默认的(即无参数的)构造方法(constructor) ............. 52 4.1.2. 提供一个标识属性(identifier property)(可选) ................. 52 4.1.3. 使用非final的类(可选) ........................................ 53 4.1.4. 为持久化字段声明访问器(accessors)和是否可变的标志(mutators) (可选) .............................................................. 53 4.2. 实现继承(Inheritance) ............................................... 53 4.3. 实现 equals() 和 hashCode() 方法: ................................... 54 4.4. 动态模型(Dynamic models) ............................................ 55 4.5. 元组片断映射(Tuplizers) ............................................. 57 4.6. EntityNameResolvers ................................................... 58 5. 对象/关系数据库映射基础(Basic O/R Mapping) ................................. 61 5.1. 映射定义(Mapping declaration) ....................................... 61 5.1.1. Doctype ........................................................ 62 5.1.2. Hibernate-mapping .............................................. 63 5.1.3. 类 ............................................................. 64 5.1.4. id ............................................................. 67 5.1.5. 增强的标识符生成器 ............................................. 71 5.1.6. 标识符生成器的优化 ............................................. 72 5.1.7. composite-id ................................................... 72 5.1.8. 鉴别器(discriminator) ........................................ 73 5.1.9. 版本(version)(可选) ........................................ 74 5.1.10. timestamp(可选) .............................................. 75 5.1.11. Property ...................................................... 76 5.1.12. 多对一(many-to-one) ......................................... 78 5.1.13. 一对一 ........................................................ 80 5.1.14. 自然 ID(natural-id) ......................................... 82 5.1.15. 组件(component)和动态组件(dynamic-component) ............... 82 5.1.16. 属性(Properties) ............................................ 83 5.1.17. 子类(subclass) .............................................. 84 5.1.18. 连接的子类(joined-subclass) ................................. 85 5.1.19. 联合子类(union-subclass) .................................... 86 5.1.20. 连接(join) .................................................. 87 5.1.21. Key ........................................................... 88 5.1.22. 字段和规则元素(column and formula elements) ................. 89 5.1.23. 引用(import) ................................................ 90 5.1.24. Any ........................................................... 90 5.2. Hibernate 的类型 ..................................................... 91 5.2.1. 实体(Entities)和值(values) ................................. 91v 5.2.2. 基本值类型 ..................................................... 92 5.2.3. 自定义值类型 ................................................... 93 5.3. 多次映射同一个类 ...................................................... 94 5.4. SQL 中引号包围的标识符 ............................................... 95 5.5. 其他元数据(Metadata) ................................................ 95 5.5.1. 使用 XDoclet 标记 ............................................. 95 5.5.2. 使用 JDK 5.0 的注解(Annotation) .............................. 97 5.6. 数据库生成属性(Generated Properties) ................................ 98 5.7. 字段的读写表达式 ...................................................... 98 5.8. 辅助数据库对象(Auxiliary Database Objects) .......................... 99 6. 集合映射(Collection mappings) ............................................ 101 6.1. 持久化集合类(Persistent collections) ............................... 101 6.2. 集合映射( Collection mappings ) ................................... 102 6.2.1. 集合外键(Collection foreign keys) ........................... 103 6.2.2. 集合元素(Collection elements) ............................... 104 6.2.3. 索引集合类(Indexed collections) ............................. 104 6.2.4. 值集合于多对多关联(Collections of values and many-to-many associations) ....................................................... 105 6.2.5. 一对多关联(One-to-many Associations) ........................ 107 6.3. 高级集合映射(Advanced collection mappings) ......................... 108 6.3.1. 有序集合(Sorted collections) ................................ 108 6.3.2. 双向关联(Bidirectional associations) ........................ 109 6.3.3. 双向关联,涉及有序集合类 ...................................... 111 6.3.4. 三重关联(Ternary associations) .............................. 112 6.3.5. Using an ............................................. 112 6.4. 集合例子(Collection example) ....................................... 113 7. 关联关系映射 ............................................................... 117 7.1. 介绍 ................................................................ 117 7.2. 单向关联(Unidirectional associations) .............................. 117 7.2.1. 多对一(many-to-one) ......................................... 117 7.2.2. 一对一(One-to-one) .......................................... 117 7.2.3. 一对多(one-to-many) ......................................... 118 7.3. 使用连接表的单向关联(Unidirectional associations with join tables) .. 119 7.3.1. 一对多(one-to-many) ......................................... 119 7.3.2. 多对一(many-to-one) ......................................... 120 7.3.3. 一对一(One-to-one) .......................................... 120 7.3.4. 多对多(many-to-many) ........................................ 121 7.4. 双向关联(Bidirectional associations) ............................... 122 7.4.1. 一对多(one to many)/多对一(many to one) .................... 122 7.4.2. 一对一(One-to-one) .......................................... 123 7.5. 使用连接表的双向关联(Bidirectional associations with join tables) ... 124 7.5.1. 一对多(one to many)/多对一(many to one) .................... 124 7.5.2. 一对一(one to one) ......................................... 125 7.5.3. 多对多(many-to-many) ........................................ 126HIBERNATE - Relational Persis... vi 7.6. 更复杂的关联映射 ..................................................... 126 8. 组件(Component)映射 ....................................................... 129 8.1. 依赖对象(Dependent objects) ........................................ 129 8.2. 在集合中出现的依赖对象(Collections of dependent objects) ........... 131 8.3. 组件作为 Map 的索引(Components as Map indices ) .................... 132 8.4. 组件作为联合标识符(Components as composite identifiers) ............ 132 8.5. 动态组件(Dynamic components) ....................................... 134 9. 继承映射(Inheritance Mapping) ............................................ 137 9.1. 三种策略 ............................................................. 137 9.1.1. 每个类分层结构一张表(Table per class hierarchy) ............. 137 9.1.2. 每个子类一张表(Table per subclass) .......................... 138 9.1.3. 每个子类一张表(Table per subclass),使用辨别标志 (Discriminator) .................................................... 138 9.1.4. 混合使用“每个类分层结构一张表”和“每个子类一张表” ........... 139 9.1.5. 每个具体类一张表(Table per concrete class) .................. 140 9.1.6. 每个具体类一张表,使用隐式多态 ................................ 141 9.1.7. 隐式多态和其他继承映射混合使用 ................................ 142 9.2. 限制 ................................................................ 142 10. 与对象共事 ................................................................ 145 10.1. Hibernate 对象状态(object states) ................................. 145 10.2. 使对象持久化 ........................................................ 145 10.3. 装载对象 ............................................................ 146 10.4. 查询 ............................................................... 148 10.4.1. 执行查询 ..................................................... 148 10.4.2. 过滤集合 ..................................................... 152 10.4.3. 条件查询(Criteria queries) ................................. 153 10.4.4. 使用原生 SQL 的查询 ......................................... 153 10.5. 修改持久对象 ........................................................ 153 10.6. 修改脱管(Detached)对象 ............................................ 154 10.7. 自动状态检测 ........................................................ 155 10.8. 删除持久对象 ........................................................ 156 10.9. 在两个不同数据库间复制对象 .......................................... 156 10.10. Session 刷出(flush) .............................................. 157 10.11. 传播性持久化(transitive persistence) ............................. 158 10.12. 使用元数据 ......................................................... 160 11. Read-only entities ........................................................ 161 11.1. Making persistent entities read-only ................................ 162 11.1.1. Entities of immutable classes ................................ 162 11.1.2. Loading persistent entities as read-only ..................... 162 11.1.3. Loading read-only entities from an HQL query/criteria ......... 163 11.1.4. Making a persistent entity read-only ......................... 165 11.2. Read-only affect on property type .................................. 166 11.2.1. Simple properties ............................................ 167 11.2.2. Unidirectional associations .................................. 167


网友评论

  • 好资源,带有书签功能,清晰!
  • 学习hibernate的*助手 好东西
  • 不错,清晰版的
  • 好资源,带有书签功能,清晰! .
  • 好资源,带有书签功能,清晰!