diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java index 23790ec320..024e34e4ff 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java @@ -2172,12 +2172,20 @@ public abstract class CollectionBinder { CollectionPropertyHolder holder, Class> compositeUserType) { //TODO be smart with isNullable + final AccessType accessType = accessType( property, collection.getOwner() ); + // We create a new entity binder here because it is needed for processing the embeddable + // Since this is an element collection, there is no real entity binder though, + // so we just create an "empty shell" for the purpose of avoiding null checks in the fillEmbeddable() method etc. + final EntityBinder entityBinder = new EntityBinder(); + // Copy over the access type that we resolve for the element collection, + // so that nested components use the same access type. This fixes HHH-15966 + entityBinder.setPropertyAccessType( accessType ); final Component component = fillEmbeddable( holder, getSpecialMembers( elementClass ), - accessType( property, collection.getOwner() ), + accessType, true, - new EntityBinder(), + entityBinder, false, false, true, diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java index 8b2fd6694d..68b6cf569b 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java @@ -2253,9 +2253,11 @@ public class EntityBinder { public AccessType getExplicitAccessType(XAnnotatedElement element) { AccessType accessType = null; - final Access access = element.getAnnotation( Access.class ); - if ( access != null ) { - accessType = AccessType.getAccessStrategy( access.value() ); + if ( element != null ) { + final Access access = element.getAnnotation( Access.class ); + if ( access != null ) { + accessType = AccessType.getAccessStrategy( access.value() ); + } } return accessType; } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/nested/fieldaccess/FieldAccessedNestedEmbeddableMetadataTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/nested/fieldaccess/FieldAccessedNestedEmbeddableMetadataTest.java index ae2fdd5990..5acc6d1c49 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/nested/fieldaccess/FieldAccessedNestedEmbeddableMetadataTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/nested/fieldaccess/FieldAccessedNestedEmbeddableMetadataTest.java @@ -33,7 +33,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; public class FieldAccessedNestedEmbeddableMetadataTest { @Test - @FailureExpected(jiraKey = "HHH-9089") public void testEnumTypeInterpretation() { StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build(); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/access/NestedEmbeddableDefaultAccessTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/access/NestedEmbeddableDefaultAccessTests.java index 07bd3c7b27..fb67032ea5 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/access/NestedEmbeddableDefaultAccessTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/access/NestedEmbeddableDefaultAccessTests.java @@ -48,10 +48,6 @@ public class NestedEmbeddableDefaultAccessTests { @Test @Jira( "https://hibernate.atlassian.net/browse/HHH-14063" ) - @FailureExpected( - reason = "When an embeddable is a key or element of a collection, access-type is " + - "not properly propagated to nested embeddables" - ) public void verifyElementCollectionMapping(DomainModelScope scope) { scope.withHierarchy( MyEntity.class, (descriptor) -> { final Property outerEmbeddedList = descriptor.getProperty( "outerEmbeddableList" ); diff --git a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/entities/components/Component4.java b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/entities/components/Component4.java index bd6d09807e..0dad3bb3e6 100644 --- a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/entities/components/Component4.java +++ b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/entities/components/Component4.java @@ -63,7 +63,6 @@ public class Component4 { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((description == null) ? 0 : description.hashCode()); result = prime * result + ((key == null) ? 0 : key.hashCode()); result = prime * result + ((value == null) ? 0 : value.hashCode()); return result; @@ -80,9 +79,6 @@ public class Component4 { Component4 other = (Component4) obj; - if ( description != null ? !description.equals( other.description ) : other.description != null ) { - return false; - } if ( key != null ? !key.equals( other.key ) : other.key != null ) { return false; }