HHH-15966 ElementCollection with nested Embeddables fails with ArrayIndexOutOfBoundsException
This commit is contained in:
parent
00018731f8
commit
b774f80ce9
|
@ -2172,12 +2172,20 @@ public abstract class CollectionBinder {
|
||||||
CollectionPropertyHolder holder,
|
CollectionPropertyHolder holder,
|
||||||
Class<? extends CompositeUserType<?>> compositeUserType) {
|
Class<? extends CompositeUserType<?>> compositeUserType) {
|
||||||
//TODO be smart with isNullable
|
//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(
|
final Component component = fillEmbeddable(
|
||||||
holder,
|
holder,
|
||||||
getSpecialMembers( elementClass ),
|
getSpecialMembers( elementClass ),
|
||||||
accessType( property, collection.getOwner() ),
|
accessType,
|
||||||
true,
|
true,
|
||||||
new EntityBinder(),
|
entityBinder,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
|
|
|
@ -2253,9 +2253,11 @@ public class EntityBinder {
|
||||||
|
|
||||||
public AccessType getExplicitAccessType(XAnnotatedElement element) {
|
public AccessType getExplicitAccessType(XAnnotatedElement element) {
|
||||||
AccessType accessType = null;
|
AccessType accessType = null;
|
||||||
final Access access = element.getAnnotation( Access.class );
|
if ( element != null ) {
|
||||||
if ( access != null ) {
|
final Access access = element.getAnnotation( Access.class );
|
||||||
accessType = AccessType.getAccessStrategy( access.value() );
|
if ( access != null ) {
|
||||||
|
accessType = AccessType.getAccessStrategy( access.value() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return accessType;
|
return accessType;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
public class FieldAccessedNestedEmbeddableMetadataTest {
|
public class FieldAccessedNestedEmbeddableMetadataTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@FailureExpected(jiraKey = "HHH-9089")
|
|
||||||
public void testEnumTypeInterpretation() {
|
public void testEnumTypeInterpretation() {
|
||||||
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build();
|
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build();
|
||||||
|
|
||||||
|
|
|
@ -48,10 +48,6 @@ public class NestedEmbeddableDefaultAccessTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Jira( "https://hibernate.atlassian.net/browse/HHH-14063" )
|
@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) {
|
public void verifyElementCollectionMapping(DomainModelScope scope) {
|
||||||
scope.withHierarchy( MyEntity.class, (descriptor) -> {
|
scope.withHierarchy( MyEntity.class, (descriptor) -> {
|
||||||
final Property outerEmbeddedList = descriptor.getProperty( "outerEmbeddableList" );
|
final Property outerEmbeddedList = descriptor.getProperty( "outerEmbeddableList" );
|
||||||
|
|
|
@ -63,7 +63,6 @@ public class Component4 {
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
|
||||||
result = prime * result + ((key == null) ? 0 : key.hashCode());
|
result = prime * result + ((key == null) ? 0 : key.hashCode());
|
||||||
result = prime * result + ((value == null) ? 0 : value.hashCode());
|
result = prime * result + ((value == null) ? 0 : value.hashCode());
|
||||||
return result;
|
return result;
|
||||||
|
@ -80,9 +79,6 @@ public class Component4 {
|
||||||
|
|
||||||
Component4 other = (Component4) obj;
|
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 ) {
|
if ( key != null ? !key.equals( other.key ) : other.key != null ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue