Skip to content

[OPENJPA-2965] Pin the bulk delete of a candidate with cascade delete fields - #199

Merged
cristof merged 1 commit into
masterfrom
OPENJPA-2965
Oct 6, 2026
Merged

cristof merged 1 commit into
masterfrom
OPENJPA-2965

Conversation

@rzo1

@rzo1 rzo1 commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

The orphaned-row concern behind this issue was fixed by OPENJPA-2990: a bulk DELETE cleans the tables the candidate owns, so the join table and element collection rows of dependent fields no longer dangle, while related entity rows are left untouched as section 4.10 requires. Nothing covered a candidate with cascade delete fields, so this adds that regression test — one dependent and one cascade=REMOVE direct relation, a dependent join table collection, a dependent bi-directional one-to-many and an element collection. The migration note described the previous @ElementCollection behaviour the wrong way round and is corrected.

… fields

Removing the cascade guard from the JDBC bulk delete strategy no longer
leaves the rows of the join tables and element collection tables behind: the
delete cleans up the tables the candidate owns itself. The guard rejected a
field whose own value had a cascade delete, which is what OpenJPA's
@dependent and a to-one cascade=REMOVE set; a collection declares its cascade
on the element value, which the guard never read, so only a single-valued
relation ever forced the delete onto the in-memory path, where the owned
tables were cleaned up as a side effect of removing every instance. Nothing
covered that shape, so a regression could pass unnoticed.

The new test deletes such a candidate - one dependent and one cascade=REMOVE
direct relation next to a dependent join table collection, a dependent
bi-directional one-to-many and an element collection - and asserts that the
join table and the element collection table are emptied while the related
entity rows survive: the targets of the direct relations, the elements of the
join table collection and the rows of the one-to-many, whose foreign key
lives in a table the candidate does not own. A bulk delete does not cascade
(specification section 4.10), so none of those rows is an owned row.

The migration note described the previous behaviour for an @ElementCollection
the wrong way round. Such a candidate already took the bulk SQL path and its
collection table rows were left behind on the deleted keys; removing them is
a fix (OPENJPA-2990), not a replacement for cascading that was lost.
@rzo1 rzo1 self-assigned this Oct 5, 2026
@rzo1
rzo1 requested review from cristof and solomax October 5, 2026 18:12
@cristof
cristof merged commit 85132b2 into master Oct 6, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants