mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-21 02:25:22 +00:00
HHH-11768 - Fix FK ConstraintViolationException with ordered inserts enabled and cascade persist.
This commit is contained in:
parent
e7e6cc53ab
commit
234849d33b
@ -1104,7 +1104,7 @@ public void sort(List<AbstractEntityInsertAction> insertions) {
|
||||
//Make sure that child entries are not before parents
|
||||
for ( int j = i - 1; j >= 0; j-- ) {
|
||||
BatchIdentifier prevBatchIdentifier = latestBatches.get( j );
|
||||
if(prevBatchIdentifier.getParentEntityNames().contains( entityName )) {
|
||||
if ( prevBatchIdentifier.getParentEntityNames().contains( entityName ) ) {
|
||||
latestBatches.remove( batchIdentifier );
|
||||
latestBatches.add( j, batchIdentifier );
|
||||
}
|
||||
@ -1114,8 +1114,12 @@ public void sort(List<AbstractEntityInsertAction> insertions) {
|
||||
for ( int j = i + 1; j < latestBatches.size(); j++ ) {
|
||||
BatchIdentifier nextBatchIdentifier = latestBatches.get( j );
|
||||
//Take care of unidirectional @OneToOne associations but exclude bidirectional @ManyToMany
|
||||
if(nextBatchIdentifier.getChildEntityNames().contains( entityName ) &&
|
||||
!batchIdentifier.getChildEntityNames().contains( nextBatchIdentifier.getEntityName() )) {
|
||||
if ( nextBatchIdentifier.getChildEntityNames().contains( entityName ) &&
|
||||
!batchIdentifier.getChildEntityNames().contains( nextBatchIdentifier.getEntityName() ) ) {
|
||||
latestBatches.remove( batchIdentifier );
|
||||
latestBatches.add( j, batchIdentifier );
|
||||
}
|
||||
else if ( batchIdentifier.getParentEntityNames().contains( nextBatchIdentifier.getEntityName() ) ) {
|
||||
latestBatches.remove( batchIdentifier );
|
||||
latestBatches.add( j, batchIdentifier );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user