BCD Session 07
BCD Session 07
Objectives
Ver. 1.0
Slide 1 of 30
Ver. 1.0
Slide 2 of 30
<<entity>>
Auction
Ver. 1.0
<<entity>>
Bid
<<entity>>
Item
Slide 3 of 30
Ver. 1.0
Slide 4 of 30
Ver. 1.0
Slide 5 of 30
Ver. 1.0
Slide 6 of 30
Ver. 1.0
Cardinality
Direction
One-to-one
Bidirectional
One-to-one
Unidirectional
One-to-many
Bidirectional
One-to-many
Unidirectional
Many-to-one
Unidirectional
Many-to-many
Bidirectional
Many-to-many
Unidirectional
Slide 7 of 30
Engine_1
Auction_1
Ver. 1.0
Item_1
Slide 8 of 30
Bid_1
OrderItem_1
Ver. 1.0
Slide 9 of 30
AccountType_1
Account_1
Ver. 1.0
Slide 10 of 30
Employee_1
Employee_2
Company_2
Employee_3
Company_3
Ver. 1.0
Employee_4
Slide 11 of 30
InventoryItem_1
InventoryItem_2
Order_2
InventoryItem_3
Order_3
Ver. 1.0
InventoryItem_4
Slide 12 of 30
Ver. 1.0
Slide 13 of 30
Ver. 1.0
@Entity
public class Customer {
@Id
private int id;
@OneToOne
private Record custRecord;
..//
}
Slide 14 of 30
Ver. 1.0
Slide 15 of 30
Ver. 1.0
Slide 16 of 30
Ver. 1.0
@Entity
public class Customer {
@Id
private int id;
@OneToOne
private Record custRecord;
..//
}
Slide 17 of 30
Ver. 1.0
Slide 18 of 30
Ver. 1.0
Slide 19 of 30
Ver. 1.0
@Entity
public class Customer {
@Id
private int id;
@OneToMany(mappedBy=customer)
private Collection <Order> orders;
..//
}
Slide 20 of 30
Ver. 1.0
@Entity
public class Order {
@Id
private int orderId;
@ManyToOne
private Customer customer;
..//
}
Slide 21 of 30
Ver. 1.0
Slide 22 of 30
Ver. 1.0
Slide 23 of 30
Ver. 1.0
@Entity
public class Worker {
@Id
private int id;
@ManyToMany
private Set <Project> projects;
..//
}
Slide 24 of 30
Ver. 1.0
Slide 25 of 30
Ver. 1.0
Slide 26 of 30
Ver. 1.0
Annotation
Default
Basic
EAGER
OneToOne
EAGER
ManyToOne
EAGER
OneToMany
LAZY
ManyToMany
LAZY
Slide 27 of 30
Ver. 1.0
Value
Comment
PERSIST
Causes the persist operation to cascade to the target entity of the association
when the entity managers persist operation is invoked on the source entity.
MERGE
Causes the merge operation to cascade to the target entity of the association
when the entity managers merge operation is invoked on the source entity.
REMOVE
Causes the remove operation to cascade to the target entity of the association
when the entity managers remove operation is invoked on the source entity.
REFRESH
Causes the refresh operation to cascade to the target entity of the association
when the entity managers refresh operation is invoked on the source entity.
ALL
Causes all the entity state change operations (persist, merge, remove, and
refresh) to cascade to the target entity of the association.
Slide 28 of 30
Cascade type
Ver. 1.0
Slide 29 of 30
Ver. 1.0
Slide 30 of 30