nerdexam
Oracle

1Z0-898 · Question #44

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?

The correct answer is C. @ OneToOne (orphanremoval = true). Orphan Removal in Relationships When a target entity in one-to-one or one-to-many relationship is removed from the relationship, it is often desirable to cascade the remove operation to the target entity. Such target entities are considered "orphans," and the orphanRemoval…

Entity Relationships

Question

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?

Exhibit

1Z0-898 question #44 exhibit

Options

  • A@OneToOne (optional = false)
  • B@OneToOne (optional = false)
  • C@ OneToOne (orphanremoval = true)
  • D@ OneToOne (cascade = ORPHAN _ DELETE)

How the community answered

(21 responses)
  • A
    10% (2)
  • B
    14% (3)
  • C
    71% (15)
  • D
    5% (1)

Explanation

Orphan Removal in Relationships When a target entity in one-to-one or one-to-many relationship is removed from the relationship, it is often desirable to cascade the remove operation to the target entity. Such target entities are considered "orphans," and the orphanRemoval attribute can be used to specify that orphaned entities should be removed. For example, if an order has many line items and one of them is removed from the order, the removed line item is considered an orphan. If orphanRemoval is set to true, the line item entity will be deleted when the line item is removed from the order. The orphanRemoval attribute in @OneToMany and @oneToOne takes a Boolean value and is by The following example will cascade the remove operation to the orphaned customer entity when it is removed from the relationship: @OneToMany(mappedBy="customer", orphanRemoval="true") public List<Order> getOrders()

Topics

#OneToOne#orphanRemoval#cascade types#entity removal

Community Discussion

No community discussion yet for this question.

Full 1Z0-898 Practice