Enterprise Java Development@TOPIC@
To provide hands on experience
Mapping relationships between JPA entity classes to a relational database
Propagating dependent primary key values derived from a parent relationship
Relating entity classes which use built-in and composite primary key types
Witnessing the functional and potential performance differences between different mapping styles and properties
At the completion of this exercise, the student will be able to
Map OneToOne, OneToMany, ManyToOne, and ManyToMany relationships to the database
Map uni-directional and bi-directional relationships to the database
Derive and propagate a primary key for a dependent entity from a relation to a parent entity
Realize relationships using foreign key joins, primary key joins, and link table joins
Realize relationships to a parent entity using a composite primary/foreign key
Enforce mandatory and allow optional relationships
Reduce interaction with the EntityManager using relationship Cascades
Impact performance through informed decisions on selecting certain relationship styles and properties
This exercise makes use of the AUTO GeneratedValue strategy and was
originally authored when that strategy was IDENTITY. As of 2018 using H2,
the strategy resolves SEQUENCE. That means that there will be an additional
set of calls to "next value" and database rows may be delayed in their
insertion. Simply add an em.flush()
to force the insert of any
new rows where there is a confusing mis-match between the instructions and
your observed output. This should be another reminder to not leverage
the AUTO strategy -- since it can change over time.