没有合适的资源?快使用搜索试试~ 我知道了~
hibernate_reference3.2.1
5星 · 超过95%的资源 需积分: 10 22 下载量 107 浏览量
2007-05-17
09:16:30
上传
评论
收藏 1017KB PDF 举报
温馨提示
试读
227页
hibernate 英文参考文档 pdf
资源推荐
资源详情
资源评论
Hibernate Reference Documentation
Version: 3.2.1
Table of Contents
Preface ..........................................................................................................................................viii
1. Introduction to Hibernate ...........................................................................................................1
1.1. Preface .............................................................................................................................. 1
1.2. Part 1 - The first Hibernate Application ...............................................................................1
1.2.1. The first class ..........................................................................................................1
1.2.2. The mapping file ..................................................................................................... 3
1.2.3. Hibernate configuration ...........................................................................................4
1.2.4. Building with Ant ....................................................................................................6
1.2.5. Startup and helpers ..................................................................................................6
1.2.6. Loading and storing objects ...................................................................................... 8
1.3. Part 2 - Mapping associations ............................................................................................ 10
1.3.1. Mapping the Person class ....................................................................................... 10
1.3.2. A unidirectional Set-based association .................................................................... 11
1.3.3. Working the association ......................................................................................... 12
1.3.4. Collection of values ............................................................................................... 13
1.3.5. Bi-directional associations ..................................................................................... 14
1.3.6. Working bi-directional links ................................................................................... 15
1.4. Part 3 - The EventManager web application ....................................................................... 16
1.4.1. Writing the basic servlet ........................................................................................ 16
1.4.2. Processing and rendering ....................................................................................... 17
1.4.3. Deploying and testing ............................................................................................ 18
1.5. Summary ......................................................................................................................... 19
2. Architecture .............................................................................................................................. 20
2.1. Overview ......................................................................................................................... 20
2.2. Instance states .................................................................................................................. 22
2.3. JMX Integration ............................................................................................................... 22
2.4. JCA Support .................................................................................................................... 23
2.5. Contextual Sessions .......................................................................................................... 23
3. Configuration ............................................................................................................................ 25
3.1. Programmatic configuration .............................................................................................. 25
3.2. Obtaining a SessionFactory ............................................................................................... 25
3.3. JDBC connections ............................................................................................................ 26
3.4. Optional configuration properties ...................................................................................... 27
3.4.1. SQL Dialects ......................................................................................................... 33
3.4.2. Outer Join Fetching ............................................................................................... 34
3.4.3. Binary Streams ...................................................................................................... 34
3.4.4. Second-level and query cache ................................................................................. 34
3.4.5. Query Language Substitution ................................................................................. 34
3.4.6. Hibernate statistics ................................................................................................ 34
3.5. Logging ........................................................................................................................... 34
3.6. Implementing a NamingStrategy ....................................................................................... 35
3.7. XML configuration file ..................................................................................................... 36
3.8. J2EE Application Server integration .................................................................................. 36
3.8.1. Transaction strategy configuration .......................................................................... 37
3.8.2. JNDI-bound SessionFactory ................................................................................... 38
3.8.3. Current Session context management with JTA ....................................................... 38
3.8.4. JMX deployment ................................................................................................... 39
4. Persistent Classes ...................................................................................................................... 41
Hibernate 3.2.1 ii
4.1. A simple POJO example ................................................................................................... 41
4.1.1. Implement a no-argument constructor ..................................................................... 42
4.1.2. Provide an identifier property (optional) .................................................................. 42
4.1.3. Prefer non-final classes (optional) ........................................................................... 42
4.1.4. Declare accessors and mutators for persistent fields (optional) .................................. 43
4.2. Implementing inheritance ................................................................................................. 43
4.3. Implementing equals() and hashCode() .............................................................................. 43
4.4. Dynamic models .............................................................................................................. 44
4.5. Tuplizers ......................................................................................................................... 46
5. Basic O/R Mapping ................................................................................................................... 48
5.1. Mapping declaration ......................................................................................................... 48
5.1.1. Doctype ................................................................................................................ 49
5.1.1.1. EntityResolver ............................................................................................ 49
5.1.2. hibernate-mapping ................................................................................................. 50
5.1.3. class ..................................................................................................................... 50
5.1.4. id .......................................................................................................................... 53
5.1.4.1. Generator ................................................................................................... 53
5.1.4.2. Hi/lo algorithm ........................................................................................... 54
5.1.4.3. UUID algorithm ......................................................................................... 55
5.1.4.4. Identity columns and sequences ................................................................... 55
5.1.4.5. Assigned identifiers .................................................................................... 55
5.1.4.6. Primary keys assigned by triggers ................................................................ 56
5.1.5. composite-id ......................................................................................................... 56
5.1.6. discriminator ......................................................................................................... 57
5.1.7. version (optional) .................................................................................................. 57
5.1.8. timestamp (optional) .............................................................................................. 58
5.1.9. property ................................................................................................................ 59
5.1.10. many-to-one ........................................................................................................ 60
5.1.11. one-to-one ........................................................................................................... 62
5.1.12. natural-id ............................................................................................................ 63
5.1.13. component, dynamic-component .......................................................................... 64
5.1.14. properties ............................................................................................................ 64
5.1.15. subclass .............................................................................................................. 65
5.1.16. joined-subclass .................................................................................................... 66
5.1.17. union-subclass ..................................................................................................... 67
5.1.18. join ..................................................................................................................... 68
5.1.19. key ..................................................................................................................... 68
5.1.20. column and formula elements ............................................................................... 69
5.1.21. import ................................................................................................................. 70
5.1.22. any ..................................................................................................................... 70
5.2. Hibernate Types ............................................................................................................... 71
5.2.1. Entities and values ................................................................................................. 71
5.2.2. Basic value types ................................................................................................... 71
5.2.3. Custom value types ............................................................................................... 73
5.3. Mapping a class more than once ........................................................................................ 74
5.4. SQL quoted identifiers ...................................................................................................... 74
5.5. Metadata alternatives ........................................................................................................ 74
5.5.1. Using XDoclet markup .......................................................................................... 74
5.5.2. Using JDK 5.0 Annotations .................................................................................... 76
5.6. Generated Properties ........................................................................................................ 77
5.7. Auxiliary Database Objects ............................................................................................... 77
6. Collection Mapping ................................................................................................................... 79
HIBERNATE - Relational Persistence for Idiomatic Java
Hibernate 3.2.1 iii
6.1. Persistent collections ........................................................................................................ 79
6.2. Collection mappings ......................................................................................................... 79
6.2.1. Collection foreign keys .......................................................................................... 81
6.2.2. Collection elements ............................................................................................... 81
6.2.3. Indexed collections ................................................................................................ 81
6.2.4. Collections of values and many-to-many associations .............................................. 82
6.2.5. One-to-many associations ...................................................................................... 84
6.3. Advanced collection mappings .......................................................................................... 84
6.3.1. Sorted collections .................................................................................................. 84
6.3.2. Bidirectional associations ....................................................................................... 85
6.3.3. Bidirectional associations with indexed collections .................................................. 86
6.3.4. Ternary associations .............................................................................................. 87
6.3.5. Using an <idbag> .................................................................................................. 88
6.4. Collection examples ......................................................................................................... 88
7. Association Mappings ............................................................................................................... 91
7.1. Introduction ..................................................................................................................... 91
7.2. Unidirectional associations ............................................................................................... 91
7.2.1. many to one .......................................................................................................... 91
7.2.2. one to one ............................................................................................................. 91
7.2.3. one to many .......................................................................................................... 92
7.3. Unidirectional associations with join tables ........................................................................ 93
7.3.1. one to many .......................................................................................................... 93
7.3.2. many to one .......................................................................................................... 93
7.3.3. one to one ............................................................................................................. 94
7.3.4. many to many ....................................................................................................... 94
7.4. Bidirectional associations ................................................................................................. 94
7.4.1. one to many / many to one ..................................................................................... 95
7.4.2. one to one ............................................................................................................. 95
7.5. Bidirectional associations with join tables .......................................................................... 96
7.5.1. one to many / many to one ..................................................................................... 96
7.5.2. one to one ............................................................................................................. 97
7.5.3. many to many ....................................................................................................... 98
7.6. More complex association mappings ................................................................................. 98
8. Component Mapping .............................................................................................................. 100
8.1. Dependent objects .......................................................................................................... 100
8.2. Collections of dependent objects ..................................................................................... 101
8.3. Components as Map indices ............................................................................................ 102
8.4. Components as composite identifiers ............................................................................... 102
8.5. Dynamic components ..................................................................................................... 104
9. Inheritance Mapping ............................................................................................................... 105
9.1. The Three Strategies ....................................................................................................... 105
9.1.1. Table per class hierarchy ...................................................................................... 105
9.1.2. Table per subclass ............................................................................................... 106
9.1.3. Table per subclass, using a discriminator ............................................................... 106
9.1.4. Mixing table per class hierarchy with table per subclass ......................................... 107
9.1.5. Table per concrete class ....................................................................................... 107
9.1.6. Table per concrete class, using implicit polymorphism ........................................... 108
9.1.7. Mixing implicit polymorphism with other inheritance mappings ............................. 109
9.2. Limitations .................................................................................................................... 109
10. Working with objects ............................................................................................................ 111
10.1. Hibernate object states .................................................................................................. 111
10.2. Making objects persistent .............................................................................................. 111
HIBERNATE - Relational Persistence for Idiomatic Java
Hibernate 3.2.1 iv
10.3. Loading an object ......................................................................................................... 112
10.4. Querying ..................................................................................................................... 113
10.4.1. Executing queries .............................................................................................. 113
10.4.1.1. Iterating results ....................................................................................... 114
10.4.1.2. Queries that return tuples ......................................................................... 114
10.4.1.3. Scalar results .......................................................................................... 114
10.4.1.4. Bind parameters ...................................................................................... 114
10.4.1.5. Pagination .............................................................................................. 115
10.4.1.6. Scrollable iteration .................................................................................. 115
10.4.1.7. Externalizing named queries .................................................................... 116
10.4.2. Filtering collections ........................................................................................... 116
10.4.3. Criteria queries .................................................................................................. 117
10.4.4. Queries in native SQL ........................................................................................ 117
10.5. Modifying persistent objects ......................................................................................... 117
10.6. Modifying detached objects .......................................................................................... 118
10.7. Automatic state detection .............................................................................................. 119
10.8. Deleting persistent objects ............................................................................................ 119
10.9. Replicating object between two different datastores ........................................................ 120
10.10. Flushing the Session ................................................................................................... 120
10.11. Transitive persistence ................................................................................................. 121
10.12. Using metadata ........................................................................................................... 122
11. Transactions And Concurrency ............................................................................................. 124
11.1. Session and transaction scopes ...................................................................................... 124
11.1.1. Unit of work ...................................................................................................... 124
11.1.2. Long conversations ............................................................................................ 125
11.1.3. Considering object identity ................................................................................. 126
11.1.4. Common issues ................................................................................................. 127
11.2. Database transaction demarcation .................................................................................. 127
11.2.1. Non-managed environment ................................................................................ 128
11.2.2. Using JTA ......................................................................................................... 129
11.2.3. Exception handling ............................................................................................ 130
11.2.4. Transaction timeout ........................................................................................... 130
11.3. Optimistic concurrency control ...................................................................................... 131
11.3.1. Application version checking ............................................................................. 131
11.3.2. Extended session and automatic versioning ......................................................... 132
11.3.3. Detached objects and automatic versioning ......................................................... 132
11.3.4. Customizing automatic versioning ...................................................................... 133
11.4. Pessimistic Locking ...................................................................................................... 133
11.5. Connection Release Modes ........................................................................................... 134
12. Interceptors and events ......................................................................................................... 136
12.1. Interceptors .................................................................................................................. 136
12.2. Event system ................................................................................................................ 137
12.3. Hibernate declarative security ....................................................................................... 138
13. Batch processing .................................................................................................................... 140
13.1. Batch inserts ................................................................................................................ 140
13.2. Batch updates ............................................................................................................... 140
13.3. The StatelessSession interface ....................................................................................... 141
13.4. DML-style operations ................................................................................................... 141
14. HQL: The Hibernate Query Language .................................................................................. 144
14.1. Case Sensitivity ............................................................................................................ 144
14.2. The from clause ............................................................................................................ 144
14.3. Associations and joins .................................................................................................. 144
HIBERNATE - Relational Persistence for Idiomatic Java
Hibernate 3.2.1 v
剩余226页未读,继续阅读
资源评论
- loveleesky2011-10-12很不错的 doc 不过是 英文版的 如果有中文版更好!
lujar
- 粉丝: 11
- 资源: 16
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功