Vijayasaradhi Danda (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNjIzNzJlOGRm...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16112?atlOrigin=eyJpIjoiNjIzNz...
) HHH-16112 (
https://hibernate.atlassian.net/browse/HHH-16112?atlOrigin=eyJpIjoiNjIzNz...
) Using hibernate.jdbc.batch_size configuration, merge operation to remove a child of
entities raises BatchedTooManyRowsAffectedException if the child to be removed also has
OneToMany relationship to other children that has to be removed as orphans. (
https://hibernate.atlassian.net/browse/HHH-16112?atlOrigin=eyJpIjoiNjIzNz...
)
Issue Type: Bug Affects Versions: 6.2.0.CR1, 6.1.6 Assignee: Unassigned Components:
hibernate-orm-modules Created: 27/Jan/2023 10:25 AM Environment: OpenJDK Runtime
Environment (build 17.0.2+8-86), Mac OS Monterey Version 12.6.2 Priority: Major Reporter:
Vijayasaradhi Danda (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
Need entities with OneToMany relationship with a depth of at least to 2. e.g.:
A OneToMany(orphanRemoval=true) > B OneToMany(orphanRemoval=true) > C
A has more than one B and the instance of B to remove from A has to have more than 1
instance of C. The OneToMany mappings should have orphanRemoval=true.
Fetch A, then remove an instance of B with more than one instance of C. e.g.:
A.remove(B);
session.merge(A);
Hibernate attempts to set the foreign key of C to null before issuing delete statement to
clear the orphaned children because of the parent B being removed from A. The operation
succeeds when hibernate.jdbc.batch_size is not set. However, if hibernate.jdbc.batch_size
is set to e.g.: 50 then the update operation for foreign keys of C before delete statement
is issued fails with:
org.hibernate.jdbc.BatchedTooManyRowsAffectedException: Batch update returned unexpected
row count from update [0] ; actual row count: 2 (if there were 2 instances of entity C in
the example); expected: 1
The issue happens in 6.1.6.Final or 6.2.0.CR1. This works as expected in 5.6.14.Final.
In pull request , see the test case named after the ticket number. In hibernate orm 5 the
same test passes.
(
https://hibernate.atlassian.net/browse/HHH-16112#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16112#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100214- sha1:c40e72a )