Implementing Entity Classes : Modelling Data Association Relationships
Objectives
Upon completion of this module, you should be able to:
- Examine association relationships in the data and object models
- Use relationship properties to define associations
- Implement one-to-one unidirectional associations
- Implement one-to-one bidirectional associations
- Implement many-to-one/one-to-many bidirectional associations
- Implement many-to-many bidirectional associations
- Implement many-to-many unidirectional associations
- Examine fetch and cascade mode settings
Relationships Within the Auction System’s Data Model
Object Model Showing Object Association Relationships
Using Relationship Properties to Define Associations
- Cardinality:
•OneToOne
•ManyToOne
•OneToMany
•ManyToMany
- Direction:
•Bidirectional
•Unidirectional
- Ownership:
•Inverse side
- Cascade type (operation propagation):
•All
•Persist
•Merge
•Remove
•Refresh
•None
Cardinality - Direction Combinations
Examples of One-to-One Relationships
One-to-One Bidirectional Relationships
One-to-One Unidirectional Relationships
Examples of One-to-Many Relationships
One-to-Many Bidirectional Relationship
One-to-Many Unidirectional Relationships
Examples of Many-to-One Relationships
Many-to-One Unidirectional Relationships
Examples of Many-to-Many Relationships
Many-to-Many bidirectional Relationships
Many-to-Many Unidirectional Relationships
Implementing One-to-One Unidirectional Association
Implementing One-to-One Bidirectional Association
Implementing One-to-Many / Many-to-One Bidirectional Association
Implementing Many-to-Many Bidirectional Association
Fetch Mode Attribute
@ManyToOne(fetch=EAGER)
private Customer customer;
- EAGER
- LAZY
Fetch Mode Default Values
Cascade Mode Attribute
@OneToOne(cascade=PERSIST)
private Customer customer;
Cascade mode attribute values
- PERSIST
- MERGE
- REMOVE
- REFRESH
- ALL
No comments:
Post a Comment