Advanced entity association mappings 172
8.1 One-to-one associations 173
Sharing a primary key 173 ■ The foreign primary key
generator 176 ■ Using a foreign key join column 179
Using a join table 180
8.2 One-to-many associations 182
Considering one-to-many bags 183 ■ Unidirectional and
bidirectional list mappings 184 ■ Optional one-to-many
with a join table 186 ■ One-to-many association in an
embeddable class 188
8.3 Many-to-many and ternary associations 190
Unidirectional and bidirectional many-to-many associations 190
Many-to-many with an intermediate entity 192 ■ Ternary
associations with components 197
8.4 Entity associations with Maps 200
One-to-many with a property key 200 ■ Key/Value ternary
relationship 201
8.5 Summary 202
9 Complex and legacy schemas 203
9.1 Improving the database schema 204
Adding auxiliary database objects 205 ■ SQL constraints 208
Creating indexes 214
9.2 Handling legacy keys 215
Mapping a natural primary key 215 ■ Mapping a
composite primary key 216 ■ Foreign keys in composite
primary keys 218 ■ Foreign keys to composite primary
keys 221 ■ Foreign key referencing non-prim