-
-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfix for wrong batch statement ordering with many2many relations #3113
Bugfix for wrong batch statement ordering with many2many relations #3113
Conversation
…o-many elements (size > 20) (cherry picked from commit e6a4bc4)
…do not conflict with the following inserts
@@ -267,8 +270,8 @@ public void clear() { | |||
private void flushBuffer(boolean reset) throws BatchedSqlException { | |||
flushQueue(queues[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We were unable to find a use of the queue at position 0. Maybe this one is unused?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok ... hmm, I need to look at that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!!
@@ -267,8 +270,8 @@ public void clear() { | |||
private void flushBuffer(boolean reset) throws BatchedSqlException { | |||
flushQueue(queues[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok ... hmm, I need to look at that.
@@ -294,7 +294,7 @@ private void saveAssocManyIntersection(boolean queue) { | |||
// build a intersection row for 'delete' | |||
IntersectionRow intRow = many.buildManyToManyMapBean(parentBean, otherDelete, publish); | |||
SpiSqlUpdate sqlDelete = intRow.createDelete(server, DeleteMode.HARD); | |||
persister.executeOrQueue(sqlDelete, transaction, queue); | |||
persister.executeOrQueue(sqlDelete, transaction, queue, BatchControl.DELETE_QUEUE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the bug fix here.
Followup to #3113, remove unused first BatchControl queue
Hello Rob,
this PR fixes an issue, when a List representing a ManyToMany-relation is cleared and then filled with (some of) the original elements. Functionally this resulted in the delete and the following insert statements to be executed within the same batch queue, because with m2m intersection tables the same queue was used for both types of SqlUpdate. The end result was that in these cases the first insert statements were executed before all delete statements were flushed, resulting in a DuplicateKeyException. Additionally, I introduced constants for the delete and insert queue positions for better readability.