| foreword |
|
xi | |
| preface |
|
xiii | |
| acknowledgments |
|
xv | |
| about this book |
|
xvi | |
| about Hibernate3 and EJB 3 |
|
xx | |
| author online |
|
xxi | |
| about the title and cover |
|
xxii | |
| 1 Understanding object/relational persistence |
|
1 | (29) |
|
|
|
3 | (4) |
|
|
|
3 | (1) |
|
|
|
4 | (1) |
|
|
|
5 | (1) |
|
Persistence in object-oriented applications |
|
|
5 | (2) |
|
1.2 The paradigm mismatch |
|
|
7 | (9) |
|
The problem of granularity |
|
|
9 | (1) |
|
|
|
10 | (1) |
|
|
|
11 | (2) |
|
Problems relating to associations |
|
|
13 | (1) |
|
The problem of object graph navigation |
|
|
14 | (1) |
|
|
|
15 | (1) |
|
1.3 Persistence layers and alternatives |
|
|
16 | (6) |
|
|
|
17 | (1) |
|
Hand-coding a persistence layer with SQL/JDBC |
|
|
18 | (1) |
|
|
|
19 | (1) |
|
Considering EJB entity beans |
|
|
20 | (1) |
|
Object-oriented database systems |
|
|
21 | (1) |
|
|
|
22 | (1) |
|
1.4 Object/relational mapping |
|
|
22 | (7) |
|
|
|
23 | (2) |
|
|
|
25 | (1) |
|
|
|
26 | (3) |
|
|
|
29 | (1) |
| 2 Introducing and integrating Hibernate |
|
30 | (29) |
|
2.1 "Hello World" with Hibernate |
|
|
31 | (5) |
|
2.2 Understanding the architecture |
|
|
36 | (5) |
|
|
|
38 | (2) |
|
|
|
40 | (1) |
|
|
|
40 | (1) |
|
|
|
41 | (1) |
|
|
|
41 | (10) |
|
Creating a SessionFactory |
|
|
42 | (3) |
|
Configuration in non-managed environments |
|
|
45 | (3) |
|
Configuration in managed environments |
|
|
48 | (3) |
|
2.4 Advanced configuration settings |
|
|
51 | (7) |
|
Using XML-based configuration |
|
|
51 | (2) |
|
JNDI-bound SessionFactory |
|
|
53 | (1) |
|
|
|
54 | (1) |
|
Java Management Extensions ([MX) |
|
|
55 | (3) |
|
|
|
58 | (1) |
| 3 Mapping persistent classes |
|
59 | (55) |
|
3.1 The CaveatEmptor application |
|
|
60 | (4) |
|
Analyzing the business domain |
|
|
61 | (1) |
|
The CaveatEmptor domain model |
|
|
61 | (3) |
|
3.2 Implementing the domain model |
|
|
64 | (11) |
|
Addressing leakage of concerns |
|
|
64 | (1) |
|
Transparent and automated persistence |
|
|
65 | (2) |
|
|
|
67 | (2) |
|
Implementing POJO associations |
|
|
69 | (4) |
|
Adding logic to accessor methods |
|
|
73 | (2) |
|
3.3 Defining the mapping metadata |
|
|
75 | (12) |
|
|
|
75 | (3) |
|
Basic property and class mappings |
|
|
78 | (6) |
|
Attribute-oriented programming |
|
|
84 | (2) |
|
Manipulating metadata at runtime |
|
|
86 | (1) |
|
3.4 Understanding object identity |
|
|
87 | (5) |
|
|
|
87 | (1) |
|
Database identity with Hibernate |
|
|
88 | (2) |
|
|
|
90 | (2) |
|
3.5 Fine-grained object models |
|
|
92 | (5) |
|
|
|
93 | (1) |
|
|
|
93 | (4) |
|
3.6 Mapping class inheritance |
|
|
97 | (8) |
|
|
|
97 | (2) |
|
Table per class hierarchy |
|
|
99 | (2) |
|
|
|
101 | (3) |
|
|
|
104 | (1) |
|
3.7 Introducing associations |
|
|
105 | (7) |
|
|
|
106 | (1) |
|
|
|
106 | (1) |
|
The simplest possible association |
|
|
107 | (1) |
|
Making the association bidirectional |
|
|
108 | (3) |
|
A parent/child relationship |
|
|
111 | (1) |
|
|
|
112 | (2) |
| 4 Working with persistent objects |
|
114 | (40) |
|
4.1 The persistence lifecycle |
|
|
115 | (11) |
|
|
|
116 | (1) |
|
|
|
117 | (1) |
|
|
|
118 | (1) |
|
The scope of object identity |
|
|
119 | (2) |
|
Outside the identity scope |
|
|
121 | (1) |
|
Implementing equals() and hashCode() |
|
|
122 | (4) |
|
4.2 The persistence manager |
|
|
126 | (5) |
|
Making an object persistent |
|
|
126 | (1) |
|
Updating the persistent state of a detached instance |
|
|
127 | (2) |
|
Retrieving a persistent object |
|
|
129 | (1) |
|
Updating a persistent object |
|
|
129 | (1) |
|
Making a persistent object transient |
|
|
129 | (1) |
|
Making a detached object transient |
|
|
130 | (1) |
|
4.3 Using transitive persistence in Hibernate |
|
|
131 | (8) |
|
Persistence by reachability |
|
|
131 | (2) |
|
Cascading persistence with Hibernate |
|
|
133 | (1) |
|
Managing auction categories |
|
|
134 | (4) |
|
Distinguishing between transient and detached instances |
|
|
138 | (1) |
|
|
|
139 | (13) |
|
Retrieving objects by identifier |
|
|
140 | (1) |
|
|
|
141 | (1) |
|
|
|
142 | (1) |
|
|
|
143 | (1) |
|
|
|
143 | (3) |
|
Selecting a fetching strategy in mappings |
|
|
146 | (5) |
|
|
|
151 | (1) |
|
|
|
152 | (2) |
| 5 Transactions, concurrency, and caching |
|
154 | (41) |
|
5.1 Transactions, concurrency, and caching |
|
|
154 | (2) |
|
5.2 Understanding database transactions |
|
|
156 | (12) |
|
JDBC and JTA transactions |
|
|
157 | (1) |
|
The Hibernate Transaction API |
|
|
158 | (2) |
|
|
|
160 | (1) |
|
Understanding isolation levels |
|
|
161 | (2) |
|
Choosing an isolation level |
|
|
163 | (2) |
|
Setting an isolation level |
|
|
165 | (1) |
|
Using pessimistic locking |
|
|
165 | (3) |
|
5.3 Working with application transactions |
|
|
168 | (7) |
|
|
|
169 | (3) |
|
|
|
172 | (2) |
|
Other ways to implement optimistic locking |
|
|
174 | (1) |
|
5.4 Caching theory and practice |
|
|
175 | (19) |
|
Caching strategies and scopes |
|
|
176 | (3) |
|
The Hibernate cache architecture |
|
|
179 | (6) |
|
|
|
185 | (9) |
|
|
|
194 | (1) |
| 6 Advanced mapping concepts |
|
195 | (46) |
|
6.1 Understanding the Hibernate type system |
|
|
196 | (15) |
|
|
|
198 | (2) |
|
|
|
200 | (11) |
|
6.2 Mapping collections of value types |
|
|
211 | (9) |
|
Sets, bags, lists, and maps |
|
|
211 | (9) |
|
6.3 Mapping entity associations |
|
|
220 | (14) |
|
|
|
220 | (5) |
|
Many-to-many associations |
|
|
225 | (9) |
|
6.4 Mapping polymorphic associations |
|
|
234 | (5) |
|
Polymorphic many-to-one associations |
|
|
234 | (2) |
|
|
|
236 | (1) |
|
Polymorphic associations and table-perconcrete-class |
|
|
237 | (2) |
|
|
|
239 | (2) |
| 7 Retrieving objects efficiently |
|
241 | (53) |
|
|
|
243 | (7) |
|
|
|
243 | (2) |
|
|
|
245 | (4) |
|
|
|
249 | (1) |
|
7.2 Basic queries for objects |
|
|
250 | (8) |
|
|
|
250 | (1) |
|
|
|
251 | (1) |
|
|
|
251 | (1) |
|
|
|
252 | (1) |
|
|
|
253 | (2) |
|
|
|
255 | (1) |
|
|
|
256 | (1) |
|
|
|
257 | (1) |
|
|
|
258 | (11) |
|
|
|
259 | (1) |
|
|
|
260 | (2) |
|
|
|
262 | (3) |
|
|
|
265 | (2) |
|
|
|
267 | (1) |
|
|
|
268 | (1) |
|
7.4 Writing report queries |
|
|
269 | (7) |
|
|
|
270 | (2) |
|
|
|
272 | (1) |
|
|
|
273 | (1) |
|
Restricting groups with having |
|
|
274 | (1) |
|
Improving performance with report queries |
|
|
275 | (1) |
|
7.5 Advanced query techniques |
|
|
276 | (10) |
|
|
|
276 | (3) |
|
|
|
279 | (2) |
|
|
|
281 | (2) |
|
|
|
283 | (3) |
|
7.6 Optimizing object retrieval |
|
|
286 | (6) |
|
Solving the n+l selects problem |
|
|
286 | (3) |
|
|
|
289 | (1) |
|
|
|
290 | (2) |
|
|
|
292 | (2) |
| 8 Writing Hibernate applications |
|
294 | (54) |
|
8.1 Designing layered applications |
|
|
295 | (25) |
|
Using Hibernate in a serolet engine |
|
|
296 | (15) |
|
Using Hibernate in an EJB container |
|
|
311 | (9) |
|
8.2 Implementing application transactions |
|
|
320 | (10) |
|
|
|
321 | (1) |
|
|
|
322 | (2) |
|
Using detached persistent objects |
|
|
324 | (1) |
|
|
|
325 | (4) |
|
Choosing an approach to application transactions |
|
|
329 | (1) |
|
8.3 Handling special kinds of data |
|
|
330 | (17) |
|
Legacy schemas and composite keys |
|
|
330 | (10) |
|
|
|
340 | (7) |
|
|
|
347 | (1) |
| 9 Using the toolset |
|
348 | (30) |
|
9.1 Development processes |
|
|
349 | (2) |
|
|
|
350 | (1) |
|
|
|
350 | (1) |
|
Middle out (metadata oriented) |
|
|
350 | (1) |
|
|
|
350 | (1) |
|
|
|
351 | (1) |
|
9.2 Automatic schema generation |
|
|
351 | (7) |
|
Preparing the mapping metadata |
|
|
352 | (3) |
|
|
|
355 | (2) |
|
|
|
357 | (1) |
|
|
|
358 | (6) |
|
|
|
358 | (2) |
|
|
|
360 | (2) |
|
|
|
362 | (1) |
|
|
|
363 | (1) |
|
9.4 Existing schemas and Middlegen |
|
|
364 | (8) |
|
|
|
364 | (2) |
|
Restricting tables and relationships |
|
|
366 | (2) |
|
Customizing the metadata generation |
|
|
368 | (2) |
|
Generating hbm2java and XDoclet metadata |
|
|
370 | (2) |
|
|
|
372 | (4) |
|
Setting value type attributes |
|
|
372 | (2) |
|
Mapping entity associations |
|
|
374 | (1) |
|
|
|
375 | (1) |
|
|
|
376 | (2) |
| appendix A: SQL fundamentals |
|
378 | (4) |
| appendix B: ORM implementation strategies |
|
382 | (6) |
|
B.1 Properties or fields? |
|
|
383 | (1) |
|
B.2 Dirty-checking strategies |
|
|
384 | (4) |
| appendix C: Back in the real world |
|
388 | (7) |
|
|
|
389 | (1) |
|
|
|
390 | (1) |
|
C.3 We don't need primary keys |
|
|
390 | (1) |
|
|
|
391 | (1) |
|
|
|
391 | (1) |
|
C.6 To synchronize or not? |
|
|
392 | (1) |
|
|
|
393 | (1) |
|
|
|
394 | (1) |
| references |
|
395 | (2) |
| index |
|
397 | |