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…
Question
An application has two entities, parson and Address. The application calls the DeletePersonsByStatus named query. Which of the following is true?
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)- A79% (27)
- B3% (1)
- C6% (2)
- D12% (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
Community Discussion
No community discussion yet for this question.
