Skip to content

Conversation

@nucleussoftwareopen
Copy link

https://hibernate.atlassian.net/browse/HHH-13410

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());
                    }
                }

… with a special case of Unidirectional Relations between 4 Entities
@NathanQingyangXu
Copy link
Contributor

Seems a good bug reporting. However, you need to add some testing case to showcase:

  1. without your code changes, the testing case would fail as reported in the ticket;
  2. without your code changes, the testing case passes.

Please refer to existing hibernate testing case for how to create the testing case.

@nucleussoftwareopen
Copy link
Author

@NathanQingyangXu I've updated code as per your review, also added test case which is passing with this fix.
Without fix ConstraintViolationException is being thrown.

@Sanne
Copy link
Member

Sanne commented Jul 21, 2020

thanks @nucleussoftwareopen and @NathanQingyangXu ! Merging..

@Sanne Sanne closed this Jul 21, 2020
gavinking added a commit to hibernate/hibernate-reactive that referenced this pull request Aug 24, 2020
@gavinking
Copy link
Member

Replicated to HR in hibernate/hibernate-reactive@477e421.

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.

5 participants