[hibernate-issues] [JIRA] (HHH-13410) "order_inserts = true" causes FK Violation when inserting with a special case of Unidirectional Relations between 4 Entities

Gajendra Kumar (JIRA) jira at hibernate.atlassian.net
Fri Jul 17 08:08:26 EDT 2020


Gajendra Kumar ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3Aa361200d-f952-4ff8-957b-25405dc1b1e0 ) *commented* on HHH-13410 ( https://hibernate.atlassian.net/browse/HHH-13410?atlOrigin=eyJpIjoiYjVlNzc0OGYzZDMyNDAxYmJmNGM1ZThlNTBjZDg0N2QiLCJwIjoiaiJ9 )

Re: "order_inserts = true" causes FK Violation when inserting with a special case of Unidirectional Relations between 4 Entities ( https://hibernate.atlassian.net/browse/HHH-13410?atlOrigin=eyJpIjoiYjVlNzc0OGYzZDMyNDAxYmJmNGM1ZThlNTBjZDg0N2QiLCJwIjoiaiJ9 )

This issue is due to below code in ActionQueue as nextBatchIdentifier.parent is assigned a parent. There can be multiple parents but with this code only one parent reference is being hold.

               for ( int j = i + 1; j < latestBatches.size(); j++ ) {
                   BatchIdentifier nextBatchIdentifier = latestBatches.get( j );

                   if ( nextBatchIdentifier.hasAnyParentEntityNames( batchIdentifier ) ) {
                       nextBatchIdentifier.parent = batchIdentifier;
                                          }
                   if ( batchIdentifier.hasAnyChildEntityNames( nextBatchIdentifier ) ) {
                       nextBatchIdentifier.parent = batchIdentifier;
                    }
               }

Fix: parent should be added to nextBatchIdentifier.parentEntityNames

               for ( int j = i + 1; j < latestBatches.size(); j++ ) {
                   BatchIdentifier nextBatchIdentifier = latestBatches.get( j );

                   if ( nextBatchIdentifier.hasAnyParentEntityNames( batchIdentifier ) ) {
                       nextBatchIdentifier.parent = batchIdentifier;
                       nextBatchIdentifier.getParentEntityNames().add(batchIdentifier.getEntityName());
                   }
                   if ( batchIdentifier.hasAnyChildEntityNames( nextBatchIdentifier ) ) {
                       nextBatchIdentifier.parent = batchIdentifier;
                       nextBatchIdentifier.getParentEntityNames().add(batchIdentifier.getEntityName());
                   }
               }

I’ll create pull request soon 🙂

( https://hibernate.atlassian.net/browse/HHH-13410#add-comment?atlOrigin=eyJpIjoiYjVlNzc0OGYzZDMyNDAxYmJmNGM1ZThlNTBjZDg0N2QiLCJwIjoiaiJ9 ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-13410#add-comment?atlOrigin=eyJpIjoiYjVlNzc0OGYzZDMyNDAxYmJmNGM1ZThlNTBjZDg0N2QiLCJwIjoiaiJ9 )

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.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100133- sha1:d093d11 )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200717/ff3e937b/attachment.html 


More information about the hibernate-issues mailing list