nerdexam
Oracle

1Z0-898 · Question #20

An application has two entities, parson and Address. The application calls the DeletePersonsByStatus named query. Which of the following is true?

The correct answer is A. The person entities are removed, but NOT their related address entities. This is a known issue, hibernate does not perform cascade delete via HQL. If you load the object and delete it using session.delete(object); then the cascade relations are respected. Not via HQL. You have either of the 3 options. Load them and call session.delete(); Load all…

JPQL

Question

An application has two entities, parson and Address. The application calls the DeletePersonsByStatus named query. Which of the following is true?

Exhibit

1Z0-898 question #20 exhibit

Options

  • AThe person entities are removed, but NOT their related address entities.
  • BThe person entities, and all their related address entities, are removed.
  • CThe DeletePersonsByStatus named query is ill-formed, and will be rejected by the persistence
  • DThe named query will fall.

How the community answered

(34 responses)
  • A
    79% (27)
  • B
    3% (1)
  • C
    6% (2)
  • D
    12% (4)

Explanation

This is a known issue, hibernate does not perform cascade delete via HQL. If you load the object and delete it using session.delete(object); then the cascade relations are respected. Not via HQL. You have either of the 3 options. * Load them and call session.delete(); * Load all the child items via HQL, delete them, and then the real objects. * Put a cascade link at the database level. So when you delete it, the DB will take care of it. but-removes-with-session-delete

Topics

#bulk delete#named query#cascade#JPQL delete

Community Discussion

No community discussion yet for this question.

Full 1Z0-898 Practice