Hibernate.org Community Documentation

HIBERNATE - Relational Persistence for Idiomatic Java

Hibernate Reference Documentation

将来的你,一定会感激现在拼命努力的自己。

3.6.10.Final

June 26, 2015


前言
1. 教程
1.1. 第一部分 - 第一个 Hibernate 应用程序
1.1.1. 设置
1.1.2. 第一个 class
1.1.3. 映射文件
1.1.4. Hibernate 配置
1.1.5. 用 Maven 构建
1.1.6. 启动和辅助类
1.1.7. 加载并存储对象
1.2. 第二部分 - 关联映射
1.2.1. 映射 Person 类
1.2.2. 单向 Set-based 的关联
1.2.3. 使关联工作
1.2.4. 值类型的集合
1.2.5. 双向关联
1.2.6. 使双向连起来
1.3. 第三部分 - EventManager web 应用程序
1.3.1. 编写基本的 servlet
1.3.2. 处理与渲染
1.3.3. 部署与测试
1.4. 总结
2. 体系结构(Architecture)
2.1. 概况(Overview)
2.1.1. Minimal architecture
2.1.2. Comprehensive architecture
2.1.3. Basic APIs
2.2. JMX 整合
2.3. 上下文相关的会话(Contextual Session)
3. 配置
3.1. 可编程的配置方式
3.2. 获得 SessionFactory
3.3. JDBC 连接
3.4. 可选的配置属性
3.4.1. SQL 方言
3.4.2. 外连接抓取(Outer Join Fetching)
3.4.3. 二进制流(Binary Streams)
3.4.4. 二级缓存与查询缓存
3.4.5. 查询语言中的替换
3.4.6. Hibernate 的统计(statistics)机制
3.5. 日志
3.6. 实现 NamingStrategy
3.7. Implementing a PersisterClassProvider
3.8. XML 配置文件
3.9. Java EE Application Server integration
3.9.1. 事务策略配置
3.9.2. JNDI 绑定的 SessionFactory
3.9.3. 在 JTA 环境下使用 Current Session context(当前 session 上下文)管理
3.9.4. JMX 部署
4. 持久化类(Persistent Classes)
4.1. 一个简单的 POJO 例子
4.1.1. 实现一个默认的(即无参数的)构造方法(constructor)
4.1.2. Provide an identifier property
4.1.3. Prefer non-final classes (semi-optional)
4.1.4. 为持久化字段声明访问器(accessors)和是否可变的标志(mutators)(可选)
4.2. 实现继承(Inheritance)
4.3. 实现 equals() 和 hashCode() 方法:
4.4. 动态模型(Dynamic models)
4.5. 元组片断映射(Tuplizers)
4.6. EntityNameResolvers
5. 对象/关系数据库映射基础(Basic O/R Mapping)
5.1. 映射定义(Mapping declaration)
5.1.1. Entity
5.1.2. Identifiers
5.1.3. Optimistic locking properties (optional)
5.1.4. Property
5.1.5. Embedded objects (aka components)
5.1.6. Inheritance strategy
5.1.7. Mapping one to one and one to many associations
5.1.8. 自然 ID(natural-id)
5.1.9. Any
5.1.10. 属性(Properties)
5.1.11. Some hbm.xml specificities
5.2. Hibernate 的类型
5.2.1. 实体(Entities)和值(values)
5.2.2. 基本值类型
5.2.3. 自定义值类型
5.3. 多次映射同一个类
5.4. SQL 中引号包围的标识符
5.5. 数据库生成属性(Generated Properties)
5.6. Column transformers: read and write expressions
5.7. 辅助数据库对象(Auxiliary Database Objects)
6. Types
6.1. Value types
6.1.1. Basic value types
6.1.2. Composite types
6.1.3. Collection types
6.2. Entity types
6.3. Significance of type categories
6.4. Custom types
6.4.1. Custom types using org.hibernate.type.Type
6.4.2. Custom types using org.hibernate.usertype.UserType
6.4.3. Custom types using org.hibernate.usertype.CompositeUserType
6.5. Type registry
7. 集合映射(Collection mappings)
7.1. 持久化集合类(Persistent collections)
7.2. How to map collections
7.2.1. 集合外键(Collection foreign keys)
7.2.2. 索引集合类(Indexed collections)
7.2.3. Collections of basic types and embeddable objects
7.3. 高级集合映射(Advanced collection mappings)
7.3.1. 有序集合(Sorted collections)
7.3.2. 双向关联(Bidirectional associations)
7.3.3. 双向关联,涉及有序集合类
7.3.4. 三重关联(Ternary associations)
7.3.5. Using an <idbag>
7.4. 集合例子(Collection example)
8. 关联关系映射
8.1. 介绍
8.2. 单向关联(Unidirectional associations)
8.2.1. 多对一(many-to-one)
8.2.2. 一对一(One-to-one)
8.2.3. 一对多(one-to-many)
8.3. 使用连接表的单向关联(Unidirectional associations with join tables)
8.3.1. 一对多(one-to-many)
8.3.2. 多对一(many-to-one)
8.3.3. 一对一(One-to-one)
8.3.4. 多对多(many-to-many)
8.4. 双向关联(Bidirectional associations)
8.4.1. 一对多(one to many)/多对一(many to one)
8.4.2. 一对一(One-to-one)
8.5. 使用连接表的双向关联(Bidirectional associations with join tables)
8.5.1. 一对多(one to many)/多对一(many to one)
8.5.2. 一对一(one to one)
8.5.3. 多对多(many-to-many)
8.6. 更复杂的关联映射
9. 组件(Component)映射
9.1. 依赖对象(Dependent objects)
9.2. 在集合中出现的依赖对象(Collections of dependent objects)
9.3. 组件作为 Map 的索引(Components as Map indices )
9.4. 组件作为联合标识符(Components as composite identifiers)
9.5. 动态组件(Dynamic components)
10. 继承映射(Inheritance Mapping)
10.1. 三种策略
10.1.1. 每个类分层结构一张表(Table per class hierarchy)
10.1.2. 每个子类一张表(Table per subclass)
10.1.3. 每个子类一张表(Table per subclass),使用辨别标志(Discriminator)
10.1.4. 混合使用“每个类分层结构一张表”和“每个子类一张表”
10.1.5. 每个具体类一张表(Table per concrete class)
10.1.6. 每个具体类一张表,使用隐式多态
10.1.7. 隐式多态和其他继承映射混合使用
10.2. 限制
11. 与对象共事
11.1. Hibernate 对象状态(object states)
11.2. 使对象持久化
11.3. 装载对象
11.4. 查询
11.4.1. 执行查询
11.4.2. 过滤集合
11.4.3. 条件查询(Criteria queries)
11.4.4. 使用原生 SQL 的查询
11.5. 修改持久对象
11.6. 修改脱管(Detached)对象
11.7. 自动状态检测
11.8. 删除持久对象
11.9. 在两个不同数据库间复制对象
11.10. Session 刷出(flush)
11.11. 传播性持久化(transitive persistence)
11.12. 使用元数据
12. Read-only entities
12.1. Making persistent entities read-only
12.1.1. Entities of immutable classes
12.1.2. Loading persistent entities as read-only
12.1.3. Loading read-only entities from an HQL query/criteria
12.1.4. Making a persistent entity read-only
12.2. Read-only affect on property type
12.2.1. Simple properties
12.2.2. Unidirectional associations
12.2.3. Bidirectional associations
13. 事务和并发
13.1. Session 和事务范围(transaction scope)
13.1.1. 操作单元(Unit of work)
13.1.2. 长对话
13.1.3. 关注对象标识(Considering object identity)
13.1.4. 常见问题
13.2. 数据库事务声明
13.2.1. 非托管环境
13.2.2. 使用 JTA
13.2.3. 异常处理
13.2.4. 事务超时
13.3. 乐观并发控制(Optimistic concurrency control)
13.3.1. 应用程序级别的版本检查(Application version checking)
13.3.2. 扩展周期的 session 和自动版本化
13.3.3. 脱管对象(deatched object)和自动版本化
13.3.4. 定制自动版本化行为
13.4. 悲观锁定(Pessimistic Locking)
13.5. 连接释放模式(Connection Release Modes)
14. 拦截器与事件(Interceptors and events)
14.1. 拦截器(Interceptors)
14.2. 事件系统(Event system)
14.3. Hibernate 的声明式安全机制
15. 批量处理(Batch processing)
15.1. 批量插入(Batch inserts)
15.2. 批量更新(Batch updates)
15.3. StatelessSession(无状态 session)接口
15.4. DML(数据操作语言)风格的操作(DML-style operations)
16. HQL: Hibernate 查询语言
16.1. 大小写敏感性问题
16.2. from 子句
16.3. 关联(Association)与连接(Join)
16.4. join 语法的形式
16.5. 引用 identifier 属性
16.6. select 子句
16.7. 聚集函数
16.8. 多态查询
16.9. where 子句
16.10. 表达式
16.11. order by 子句
16.12. group by 子句
16.13. 子查询
16.14. HQL 示例
16.15. 批量的 UPDATE 和 DELETE
16.16. 小技巧 & 小窍门
16.17. 组件
16.18. Row value 构造函数语法
17. 条件查询(Criteria Queries)
17.1. 创建一个 Criteria 实例
17.2. 限制结果集内容
17.3. 结果集排序
17.4. 关联
17.5. 动态关联抓取
17.6. 查询示例
17.7. 投影(Projections)、聚合(aggregation)和分组(grouping)
17.8. 离线(detached)查询和子查询
17.9. 根据自然标识查询(Queries by natural identifier)
18. Native SQL 查询
18.1. 使用 SQLQuery
18.1.1. 标量查询(Scalar queries)
18.1.2. 实体查询(Entity queries)
18.1.3. 处理关联和集合类(Handling associations and collections)
18.1.4. 返回多个实体(Returning multiple entities)
18.1.5. 返回非受管实体(Returning non-managed entities)
18.1.6. 处理继承(Handling inheritance)
18.1.7. 参数(Parameters)
18.2. 命名 SQL 查询
18.2.1. 使用 return-property 来明确地指定字段/别名
18.2.2. 使用存储过程来查询
18.3. 定制 SQL 用来 create,update 和 delete
18.4. 定制装载 SQL
19. 过滤数据
19.1. Hibernate 过滤器(filters)
20. XML 映射
20.1. 用 XML 数据进行工作
20.1.1. 指定同时映射 XML 和类
20.1.2. 只定义 XML 映射
20.2. XML 映射元数据
20.3. 操作 XML 数据
21. 提升性能
21.1. 抓取策略(Fetching strategies)
21.1.1. 操作延迟加载的关联
21.1.2. 调整抓取策略(Tuning fetch strategies)
21.1.3. 单端关联代理(Single-ended association proxies)
21.1.4. 实例化集合和代理(Initializing collections and proxies)
21.1.5. 使用批量抓取(Using batch fetching)
21.1.6. 使用子查询抓取(Using subselect fetching)
21.1.7. Fetch profile(抓取策略)
21.1.8. 使用延迟属性抓取(Using lazy property fetching)
21.2. 二级缓存(The Second Level Cache)
21.2.1. 缓存映射(Cache mappings)
21.2.2. 策略:只读缓存(Strategy:read only)
21.2.3. 策略:读写/缓存(Strategy:read/write)
21.2.4. 策略:非严格读/写缓存(Strategy:nonstrict read/write)
21.2.5. 策略:事务缓存(transactional)
21.2.6. 各种缓存提供商/缓存并发策略的兼容性
21.3. 管理缓存(Managing the caches)
21.4. 查询缓存(The Query Cache)
21.4.1. 启用查询缓存
21.4.2. 查询缓存区
21.5. 理解集合性能(Understanding Collection performance)
21.5.1. 分类(Taxonomy)
21.5.2. Lists,maps 和 sets 用于更新效率最高
21.5.3. Bag 和 list 是反向集合类中效率最高的
21.5.4. 一次性删除(One shot delete)
21.6. 监测性能(Monitoring performance)
21.6.1. 监测 SessionFactory
21.6.2. 数据记录(Metrics)
22. 工具箱指南
22.1. Schema 自动生成(Automatic schema generation)
22.1.1. 对 schema 定制化(Customizing the schema)
22.1.2. 运行该工具
22.1.3. 属性(Properties)
22.1.4. 使用 Ant(Using Ant)
22.1.5. 对 schema 的增量更新(Incremental schema updates)
22.1.6. 用 Ant 来增量更新 schema(Using Ant for incremental schema updates)
22.1.7. Schema 校验
22.1.8. 使用 Ant 进行 schema 校验
23. Additional modules
23.1. Bean Validation
23.1.1. Adding Bean Validation
23.1.2. Configuration
23.1.3. Catching violations
23.1.4. Database schema
23.2. Hibernate Search
23.2.1. Description
23.2.2. Integration with Hibernate Annotations
24. 示例:父子关系(Parent/Child)
24.1. 关于 collections 需要注意的一点
24.2. 双向的一对多关系(Bidirectional one-to-many)
24.3. 级联生命周期(Cascading lifecycle)
24.4. 级联与未保存值(unsaved-value)
24.5. 结论
25. 示例:Weblog 应用程序
25.1. 持久化类(Persistent Classes)
25.2. Hibernate 映射
25.3. Hibernate 代码
26. 示例:复杂映射实例
26.1. Employer(雇主)/Employee(雇员)
26.2. Author(作家)/Work(作品)
26.3. Customer(客户)/Order(订单)/Product(产品)
26.4. 杂例
26.4.1. "Typed" 一对一关联
26.4.2. 组合键示例
26.4.3. 共有组合键属性的多对多(Many-to-many with shared composite key attribute)
26.4.4. 基于内容的识别
26.4.5. 备用键的联合
27. 最佳实践(Best Practices)
28. 数据库移植性考量
28.1. 移植性基础
28.2. Dialect
28.3. 方言的使用
28.4. 标识符的生成
28.5. 数据库函数
28.6. 类型映射
参考资料