Part II. Mapping, Queries

Table of Contents

5. Basic Mappings
Annotation versus XML
Annotation mapping
Mapping fields
Where to put annotations
XML Mapping
Field mapping
Class mapping
6. Primary key mapping
Natural versus Surrogate Ids
Assigned Id
Generated with Auto Strategy
Other Annotation Strategies
Composite Id
Equals and Hashcode
Other XML Id tags
7. Relation mapping
Selecting between List, Set, Map or array to hold many side
Uni- and Bi-directional relations
1:1 relation
Recursive relation
Typed relation (XML only)
Typed relation (annotation workaround)
8. Components = Composition mapping
Composition versus entity relations
Composed class in one table
Composition as set of many classes
Equals implementation
Composition as list of many classes
Advanced details
Composition 1:n:1
Not included mappings
9. Inheritance
Use Case
Overview on mapping approaches
Single Table
Joined Inheritance
Joined Inheritance with Discriminator
Mixing Single table and Joined
Union Inheritance
XML Includes
Mapped Super Class
10. Lob with Oracle and PostgreSQL
11. Querying data
Useful tools
Beam me into the code
JBoss Tools
Squirrel SQL Client
Select objects, scalars, etc
Simple select
Select with a unique result
Select with join returning multiple objects
Select with join returning one object
Select with join returning distinct results
Selecting a single column (scalar values)
Selecting multiple columns (scalar values)
Selecting objects and scalar values
Selecting selective properties of a class
Simple where condition
Walking through relations
Where condition in a related object
Where condition with parameters
Conditions on collections
Where condition with mapped class
Where condition with mapped class on the multiple side
All, In, Some, Exists, Any elements queries
Criteria Queries
Simple select
Select with a unique result
Select with join returning objects multiple times
Select with join returning distinct objects
Select with a where condition on a related object
Selecting a single column (scalar values, projections)
Simple where condition
Where condition in relation
Where with or condition
Conditions on collections
All, In, Some, Any elements queries
Native SQL
SQL to Entity
SQL Resultset Mapping
Named SQL Queries
JDBC Connection