HHH-15866 Handle DependantValue when building embedded attr mapping

This commit is contained in:
Marco Belladelli 2023-01-02 17:15:05 +01:00 committed by Christian Beikov
parent 461383c8d1
commit 60fc0c018a
2 changed files with 19 additions and 2 deletions

View File

@ -29,6 +29,7 @@ import org.hibernate.mapping.Any;
import org.hibernate.mapping.BasicValue;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.DependantValue;
import org.hibernate.mapping.IndexedConsumer;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.Selectable;
@ -92,6 +93,7 @@ public class EmbeddableMappingTypeImpl extends AbstractEmbeddableMapping impleme
null,
null,
null,
null,
insertability,
updateability,
embeddedPartBuilder,
@ -105,6 +107,7 @@ public class EmbeddableMappingTypeImpl extends AbstractEmbeddableMapping impleme
String rootTableExpression,
String[] rootTableKeyColumnNames,
Property componentProperty,
DependantValue dependantValue,
boolean[] insertability,
boolean[] updateability,
Function<EmbeddableMappingType,EmbeddableValuedModelPart> embeddedPartBuilder,
@ -130,6 +133,7 @@ public class EmbeddableMappingTypeImpl extends AbstractEmbeddableMapping impleme
compositeType,
rootTableExpression,
rootTableKeyColumnNames,
dependantValue,
insertability,
updateability,
creationProcess
@ -294,6 +298,7 @@ public class EmbeddableMappingTypeImpl extends AbstractEmbeddableMapping impleme
CompositeType compositeType,
String rootTableExpression,
String[] rootTableKeyColumnNames,
DependantValue dependantValue,
boolean[] insertability,
boolean[] updateability,
MappingModelCreationProcess creationProcess) {
@ -344,7 +349,9 @@ public class EmbeddableMappingTypeImpl extends AbstractEmbeddableMapping impleme
final Value value = bootPropertyDescriptor.getValue();
if ( subtype instanceof BasicType ) {
final BasicValue basicValue = (BasicValue) value;
final Selectable selectable = basicValue.getColumn();
final Selectable selectable = dependantValue != null ?
dependantValue.getColumns().get( columnPosition ) :
basicValue.getColumn();
final String containingTableExpression;
final String columnExpression;
if ( rootTableKeyColumnNames == null ) {

View File

@ -31,6 +31,7 @@ import org.hibernate.mapping.Any;
import org.hibernate.mapping.BasicValue;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.DependantValue;
import org.hibernate.mapping.IndexedCollection;
import org.hibernate.mapping.KeyValue;
import org.hibernate.mapping.ManyToOne;
@ -134,6 +135,7 @@ public class MappingModelCreationHelper {
rootTableName,
rootTableKeyColumnNames,
bootProperty,
null,
component.getColumnInsertability(),
component.getColumnUpdateability(),
embeddable -> new EmbeddedIdentifierMappingImpl(
@ -266,13 +268,21 @@ public class MappingModelCreationHelper {
creationProcess
);
final Component component = (Component) bootProperty.getValue();
Value componentValue = bootProperty.getValue();
DependantValue dependantValue = null;
if ( componentValue instanceof DependantValue ) {
dependantValue = ( (DependantValue) componentValue );
componentValue = dependantValue.getWrappedValue();
}
final Component component = (Component) componentValue;
final EmbeddableMappingTypeImpl embeddableMappingType = EmbeddableMappingTypeImpl.from(
component,
attrType,
tableExpression,
rootTableKeyColumnNames,
bootProperty,
dependantValue,
component.getColumnInsertability(),
component.getColumnUpdateability(),
attributeMappingType -> {