Skip to content

Commit

Permalink
HHH-15866 Handle DependantValue when building embedded attr mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
mbladel authored and beikov committed Jan 4, 2023
1 parent 461383c commit 60fc0c0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Expand Up @@ -29,6 +29,7 @@
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;
Expand Down Expand Up @@ -92,6 +93,7 @@ public static EmbeddableMappingTypeImpl from(
null,
null,
null,
null,
insertability,
updateability,
embeddedPartBuilder,
Expand All @@ -105,6 +107,7 @@ public static EmbeddableMappingTypeImpl from(
String rootTableExpression,
String[] rootTableKeyColumnNames,
Property componentProperty,
DependantValue dependantValue,
boolean[] insertability,
boolean[] updateability,
Function<EmbeddableMappingType,EmbeddableValuedModelPart> embeddedPartBuilder,
Expand All @@ -130,6 +133,7 @@ public static EmbeddableMappingTypeImpl from(
compositeType,
rootTableExpression,
rootTableKeyColumnNames,
dependantValue,
insertability,
updateability,
creationProcess
Expand Down Expand Up @@ -294,6 +298,7 @@ private boolean finishInitialization(
CompositeType compositeType,
String rootTableExpression,
String[] rootTableKeyColumnNames,
DependantValue dependantValue,
boolean[] insertability,
boolean[] updateability,
MappingModelCreationProcess creationProcess) {
Expand Down Expand Up @@ -344,7 +349,9 @@ private boolean finishInitialization(
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 ) {
Expand Down
Expand Up @@ -31,6 +31,7 @@
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;
Expand Down Expand Up @@ -134,6 +135,7 @@ public static EntityIdentifierMapping buildEncapsulatedCompositeIdentifierMappin
rootTableName,
rootTableKeyColumnNames,
bootProperty,
null,
component.getColumnInsertability(),
component.getColumnUpdateability(),
embeddable -> new EmbeddedIdentifierMappingImpl(
Expand Down Expand Up @@ -266,13 +268,21 @@ public static EmbeddedAttributeMapping buildEmbeddedAttributeMapping(
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 -> {
Expand Down

0 comments on commit 60fc0c0

Please sign in to comment.