Cascade Annotations Flashcards

1
Q

CascadeType.PERSIST

A

When the parent is persisted, the child entities are also persisted
@OneToMany(mappedBy = “parent”, cascade = CascadeType.PERSIST)
private List<Child> children;</Child>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

CascadeType.MERGE

A

When the parent is merged (updated), the child entities are also merged.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

CascadeType.REMOVE

A

When the parent is removed, the child entities are also removed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

CascadeType.REFRESH

A

When the parent is refreshed, the child entities are also refreshed to reflect the latest state from the database.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

CascadeType.DETACH

A

When the parent is detached, the child entities are also detached.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

CascadeType.ALL

A

Includes all of the above cascade types.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Example

A

@OneToMany(mappedBy = “parent”, cascade = CascadeType.ALL, orphanRemoval = true)
private List<Child> children = new ArrayList<>();
When you save or delete a Parent entity, the associated Child entities will also be saved or deleted.</Child>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly