Given two entities with one to-one association:
Which code fragment correctly defines the detail field that PersonDetail instance in removed if the person instance that references it is removed?
A.
@OneToOne (optional = false)
personDetail detail;
B.
@OneToOne (optional = false)
@mapsId
PersonDetail Detail;
C.
@ OneToOne (orphanremoval = true)
PersonDetail Detail;
D.
@ OneToOne (cascade = ORPHAN _ DELETE)
@mapsId
PersonDetail detail;
Correct tested it 🙂
ANSWER C :
If orphanRemoval is true and an entity that is the target of the relationship is removed from the relationship (either by removal from the collection or by setting the relationship to null), the remove operation will be applied to the entity being orphaned.
ORPHAN_DELETE is not a valid CascadeType value. Valid values are :
ALL
DETACH
MERGE
PERSIST
REFRESH
REMOVE