From 6a403fa5d93254d2c93a65f0a6ee7ff970abc3fe Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Wed, 27 Nov 2019 10:53:35 +0000 Subject: [PATCH] Fix delete of entity with plural attributes --- .../domain/collection/DelayedCollectionAssembler.java | 3 +++ .../metamodel/mapping/collections/MapOperationTests.java | 5 ----- .../metamodel/mapping/collections/SetOperationTests.java | 1 - 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/DelayedCollectionAssembler.java b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/DelayedCollectionAssembler.java index 8f629c773f..1b7b5eaf9c 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/DelayedCollectionAssembler.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/DelayedCollectionAssembler.java @@ -91,6 +91,8 @@ public class DelayedCollectionAssembler implements DomainResultAssembler { fetchedMapping.getCollectionDescriptor(), parentAccess.getParentKey() ); + + parentAccess.registerResolutionListener( owner -> instance.setOwner( owner ) ); } @Override @@ -137,6 +139,7 @@ public class DelayedCollectionAssembler implements DomainResultAssembler { @Override public void finishUpRow(RowProcessingState rowProcessingState) { + collectionKey = null; instance = null; } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/metamodel/mapping/collections/MapOperationTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/metamodel/mapping/collections/MapOperationTests.java index 364925572a..b0c14ade76 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/metamodel/mapping/collections/MapOperationTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/metamodel/mapping/collections/MapOperationTests.java @@ -87,11 +87,6 @@ public class MapOperationTests { } @Test - @FailureExpected( - reason = "As noted in `#dropData` there is a problem with @ElementCollections not be handled properly " + - "for cascade; `org.hibernate.tuple.NonIdentifierAttribute#getCascadeStyle` returns CascadeStyles.NONE " + - "which leads to `EntityPersister#hasCascades` to report false which leads to Cascades skipping it" - ) public void testDelete(SessionFactoryScope scope) { scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/metamodel/mapping/collections/SetOperationTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/metamodel/mapping/collections/SetOperationTests.java index 9ebb4997ad..5859b22020 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/metamodel/mapping/collections/SetOperationTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/metamodel/mapping/collections/SetOperationTests.java @@ -110,7 +110,6 @@ public class SetOperationTests { } @Test - @FailureExpected( reason = "FlushVisitor collection handling" ) public void testDeleteWithElementCollectionData(SessionFactoryScope scope) { scope.inTransaction( session -> {