HHH-17126 Improve type narrowing in signatures of EmbeddableMappingType

This commit is contained in:
Sanne Grinovero 2023-08-23 11:39:08 +02:00 committed by Sanne Grinovero
parent f58b7e4d29
commit 1e6ee8fbab
5 changed files with 12 additions and 19 deletions

View File

@ -45,6 +45,11 @@ public interface EmbeddableMappingType extends ManagedMappingType, SelectableMap
return getAggregateMapping() != null;
}
@Override
default EmbeddableMappingType getPartMappingType() {
return this;
}
default boolean shouldMutateAggregateMapping() {
// For insert and update we always want to mutate the whole aggregate
return getAggregateMapping() != null;

View File

@ -26,7 +26,6 @@ import org.hibernate.metamodel.mapping.EmbeddableMappingType;
import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart;
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.MappingType;
import org.hibernate.metamodel.mapping.ModelPart;
import org.hibernate.metamodel.mapping.SelectableConsumer;
import org.hibernate.metamodel.mapping.SelectableMapping;
@ -158,11 +157,6 @@ public class AnonymousTupleEmbeddableValuedModelPart implements EmbeddableValued
}
}
@Override
public MappingType getPartMappingType() {
return this;
}
@Override
public JavaType<?> getJavaType() {
return domainType.getExpressibleJavaType();

View File

@ -7,20 +7,15 @@
package org.hibernate.query.derived;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.hibernate.Incubating;
import org.hibernate.engine.spi.IdentifierValue;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.metamodel.mapping.CompositeIdentifierMapping;
import org.hibernate.metamodel.mapping.EmbeddableMappingType;
import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart;
import org.hibernate.metamodel.mapping.ModelPart;
import org.hibernate.metamodel.mapping.internal.SingleAttributeIdentifierMapping;
import org.hibernate.metamodel.model.domain.DomainType;
import org.hibernate.metamodel.model.domain.SingularPersistentAttribute;
import org.hibernate.property.access.spi.PropertyAccess;
import org.hibernate.query.sqm.SqmExpressible;
import org.hibernate.sql.ast.spi.SqlSelection;
@ -90,6 +85,11 @@ public class AnonymousTupleEmbeddedEntityIdentifierMapping extends AnonymousTupl
return ((SingleAttributeIdentifierMapping) delegate).getPropertyAccess();
}
@Override
public EmbeddableMappingType getPartMappingType() {
return this;
}
@Override
public int compare(Object value1, Object value2) {
return super.compare( value1, value2 );
@ -115,8 +115,4 @@ public class AnonymousTupleEmbeddedEntityIdentifierMapping extends AnonymousTupl
return this;
}
@Override
public EmbeddableMappingType getPartMappingType() {
return (EmbeddableMappingType) super.getPartMappingType();
}
}

View File

@ -7,7 +7,6 @@
package org.hibernate.query.derived;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.hibernate.Incubating;
@ -16,7 +15,6 @@ import org.hibernate.engine.FetchTiming;
import org.hibernate.engine.spi.IdentifierValue;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.metamodel.mapping.EmbeddableMappingType;
import org.hibernate.metamodel.mapping.ModelPart;
import org.hibernate.metamodel.mapping.NonAggregatedIdentifierMapping;
import org.hibernate.metamodel.mapping.internal.IdClassEmbeddable;
import org.hibernate.metamodel.mapping.internal.VirtualIdEmbeddable;
@ -107,7 +105,7 @@ public class AnonymousTupleNonAggregatedEntityIdentifierMapping extends Anonymou
@Override
public EmbeddableMappingType getPartMappingType() {
return (EmbeddableMappingType) super.getPartMappingType();
return this;
}
@Override

View File

@ -114,7 +114,7 @@ public class EmbeddableForeignKeyResultImpl<T>
@Override
public EmbeddableMappingType getReferencedMappingType() {
return (EmbeddableMappingType) getFetchContainer().getPartMappingType();
return fetchContainer.getPartMappingType();
}
@Override