Enterprise Java Development@TOPIC@

Java Persistence API: Relations

Mapping Entity Relations to the Database

Revision: v2013-10-01

2014-03-07 00:05 EST

Abstract

This presentation provides information for mapping Java entity class relationships to the database using JPA.


Purpose
1. Goals
2. Objectives
1. One-to-One Relationships
1.1. One-to-One: Uni-directional
1.2. @OneToOne Annotation
1.3. @JoinColumn Annotation
1.4. @JoinColumns Annotation
1.5. One-to-One: Bi-directional
1.6. Bi-directional Relationships and Ownership
1.7. Other Topics
1.8. Summary
2. One-to-Many Relationships
2.1. One-to-Many: Uni-directional
2.2. @OneToMany Annotation
2.3. One-to-Many: Bi-directional
2.4. @ManyToOne Annotation
2.5. One-to-Many: Element Collection
2.6. @ElementCollection Annotation
2.7. Other Topics
2.8. Summary
3. Relationship Capabilities
3.1. Fetching
3.1.1. fetch=LAZY
3.1.2. fetch=EAGER
3.2. Cascades
3.3. Orphan Removal
3.4. Summary
4. Object Collections
4.1. Object Identity
4.1.1. Instance Id
4.1.2. Primary Key Id
4.1.3. Switching Ids
4.1.4. Business Id
4.2. Collection Types
4.3. Summary
5. Foreign Keys
5.1. Primary Key Join
5.1.1. @PrimaryKeyJoinAnnotation
5.2. Using Composite Primary Key Property as Foreign Key
5.2.1. Using @IdClass Composite Primary Key Property as Foreign Key
5.2.2. Using @EmbeddedId Composite Primary Key Property as Foreign Key
5.3. Using Foreign Key in Composite Primary Key
5.3.1. Using Foreign Key in @IdClass Composite Primary Key
5.3.2. Using Foreign Key in @EmbeddedId Composite Primary Key (@MapsId)
5.4. Join Tables
5.4.1. @JoinTable Annotation
5.5. Summary
6. Many-to-One Relationships
6.1. Many-to-One: Uni-directional
6.2. Summary
7. Many-to-Many Relationships
7.1. Many-to-Many: Uni-directional
7.2. Many-to-Many: Bi-directional
7.3. Summary