some misc code cleanups
Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
parent
0dd2defc89
commit
56e0893b3a
|
@ -8,14 +8,7 @@ package org.hibernate.metamodel.mapping;
|
|||
|
||||
import org.hibernate.engine.FetchStyle;
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.spi.NavigablePath;
|
||||
import org.hibernate.sql.ast.spi.SqlAstCreationState;
|
||||
import org.hibernate.sql.ast.tree.expression.Expression;
|
||||
import org.hibernate.sql.ast.tree.from.TableGroup;
|
||||
import org.hibernate.sql.results.graph.DomainResultCreationState;
|
||||
import org.hibernate.sql.results.graph.FetchOptions;
|
||||
import org.hibernate.sql.results.graph.FetchParent;
|
||||
import org.hibernate.sql.results.graph.basic.BasicFetch;
|
||||
|
||||
/**
|
||||
* Details about the discriminator for an entity hierarchy.
|
||||
|
|
|
@ -18,7 +18,6 @@ import org.hibernate.metamodel.mapping.EntityMappingType;
|
|||
import org.hibernate.metamodel.mapping.JdbcMapping;
|
||||
import org.hibernate.metamodel.mapping.ManagedMappingType;
|
||||
import org.hibernate.metamodel.mapping.MappingType;
|
||||
import org.hibernate.metamodel.mapping.SelectableConsumer;
|
||||
import org.hibernate.metamodel.model.domain.NavigableRole;
|
||||
import org.hibernate.spi.NavigablePath;
|
||||
import org.hibernate.sql.ast.spi.SqlAstCreationState;
|
||||
|
@ -35,7 +34,7 @@ import org.hibernate.type.descriptor.java.JavaType;
|
|||
|
||||
/**
|
||||
* @implNote `discriminatorType` represents the mapping to Class, whereas `discriminatorType.getUnderlyingType()`
|
||||
* represents the "raw" JDBC mapping (String, Integer, etc)
|
||||
* represents the "raw" JDBC mapping (String, Integer, etc.)
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
|
@ -53,7 +52,7 @@ public abstract class AbstractDiscriminatorMapping implements EntityDiscriminato
|
|||
this.underlyingJdbcMapping = underlyingJdbcMapping;
|
||||
this.mappingType = mappingType;
|
||||
|
||||
this.role = mappingType.getNavigableRole().append( EntityDiscriminatorMapping.DISCRIMINATOR_ROLE_NAME );
|
||||
this.role = mappingType.getNavigableRole().append( DISCRIMINATOR_ROLE_NAME );
|
||||
|
||||
this.discriminatorType = discriminatorType;
|
||||
}
|
||||
|
@ -244,10 +243,4 @@ public abstract class AbstractDiscriminatorMapping implements EntityDiscriminato
|
|||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int forEachSelectable(int offset, SelectableConsumer consumer) {
|
||||
consumer.accept( offset, this );
|
||||
return getJdbcTypeCount();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ import org.hibernate.metamodel.mapping.DiscriminatedAssociationModelPart;
|
|||
import org.hibernate.metamodel.mapping.EntityMappingType;
|
||||
import org.hibernate.metamodel.mapping.JdbcMapping;
|
||||
import org.hibernate.metamodel.mapping.MappingType;
|
||||
import org.hibernate.metamodel.mapping.SelectableConsumer;
|
||||
import org.hibernate.metamodel.model.domain.NavigableRole;
|
||||
import org.hibernate.spi.NavigablePath;
|
||||
import org.hibernate.sql.ast.spi.FromClauseAccess;
|
||||
|
@ -263,12 +262,6 @@ public class AnyKeyPart implements BasicValuedModelPart, FetchOptions {
|
|||
return FetchTiming.IMMEDIATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int forEachSelectable(int offset, SelectableConsumer consumer) {
|
||||
consumer.accept( offset, this );
|
||||
return getJdbcTypeCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <X, Y> int breakDownJdbcValues(
|
||||
Object domainValue,
|
||||
|
|
|
@ -109,12 +109,9 @@ public class BasicAttributeMapping
|
|||
this.tableExpression = tableExpression;
|
||||
this.mappedColumnExpression = mappedColumnExpression;
|
||||
this.temporalPrecision = temporalPrecision;
|
||||
if ( selectablePath == null ) {
|
||||
this.selectablePath = new SelectablePath( mappedColumnExpression );
|
||||
}
|
||||
else {
|
||||
this.selectablePath = selectablePath;
|
||||
}
|
||||
this.selectablePath = selectablePath == null
|
||||
? new SelectablePath( mappedColumnExpression )
|
||||
: selectablePath;
|
||||
this.isFormula = isFormula;
|
||||
this.columnDefinition = columnDefinition;
|
||||
this.length = length;
|
||||
|
@ -153,8 +150,7 @@ public class BasicAttributeMapping
|
|||
String attributeName = null;
|
||||
int stateArrayPosition = 0;
|
||||
AttributeMetadata attributeMetadata;
|
||||
if ( original instanceof SingleAttributeIdentifierMapping ) {
|
||||
final SingleAttributeIdentifierMapping mapping = (SingleAttributeIdentifierMapping) original;
|
||||
if ( original instanceof SingleAttributeIdentifierMapping mapping ) {
|
||||
attributeName = mapping.getAttributeName();
|
||||
attributeMetadata = new SimpleAttributeMetadata(
|
||||
propertyAccess,
|
||||
|
@ -166,8 +162,7 @@ public class BasicAttributeMapping
|
|||
true
|
||||
);
|
||||
}
|
||||
else if ( original instanceof SingularAttributeMapping ) {
|
||||
final SingularAttributeMapping mapping = (SingularAttributeMapping) original;
|
||||
else if ( original instanceof SingularAttributeMapping mapping ) {
|
||||
attributeName = mapping.getAttributeName();
|
||||
stateArrayPosition = mapping.getStateArrayPosition();
|
||||
attributeMetadata = mapping.getAttributeMetadata();
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.hibernate.metamodel.mapping.EntityMappingType;
|
|||
import org.hibernate.metamodel.mapping.JdbcMapping;
|
||||
import org.hibernate.metamodel.mapping.JdbcMappingContainer;
|
||||
import org.hibernate.metamodel.mapping.MappingType;
|
||||
import org.hibernate.metamodel.mapping.SelectableConsumer;
|
||||
import org.hibernate.metamodel.model.domain.NavigableRole;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.property.access.spi.PropertyAccess;
|
||||
|
@ -180,12 +179,6 @@ public class BasicEntityIdentifierMappingImpl implements BasicEntityIdentifierMa
|
|||
return getJdbcMapping()::getJavaTypeDescriptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int forEachSelectable(int offset, SelectableConsumer consumer) {
|
||||
consumer.accept( offset, this );
|
||||
return getJdbcTypeCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <X, Y> int breakDownJdbcValues(
|
||||
Object domainValue,
|
||||
|
|
|
@ -55,7 +55,9 @@ public class CaseStatementDiscriminatorMappingImpl extends AbstractDiscriminator
|
|||
boolean[] discriminatorAbstract,
|
||||
DiscriminatorType<?> incomingDiscriminatorType) {
|
||||
//noinspection unchecked
|
||||
super( entityDescriptor, (DiscriminatorType<Object>) incomingDiscriminatorType, (BasicType<Object>) incomingDiscriminatorType.getUnderlyingJdbcMapping() );
|
||||
super( entityDescriptor,
|
||||
(DiscriminatorType<Object>) incomingDiscriminatorType,
|
||||
(BasicType<Object>) incomingDiscriminatorType.getUnderlyingJdbcMapping() );
|
||||
|
||||
for ( int i = 0; i < discriminatorValues.length; i++ ) {
|
||||
if ( !discriminatorAbstract[i] ) {
|
||||
|
|
|
@ -19,7 +19,6 @@ import org.hibernate.metamodel.mapping.EntityMappingType;
|
|||
import org.hibernate.metamodel.mapping.JdbcMapping;
|
||||
import org.hibernate.metamodel.mapping.MappingType;
|
||||
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
|
||||
import org.hibernate.metamodel.mapping.SelectableConsumer;
|
||||
import org.hibernate.metamodel.model.domain.NavigableRole;
|
||||
import org.hibernate.persister.collection.CollectionPersister;
|
||||
import org.hibernate.spi.NavigablePath;
|
||||
|
@ -207,12 +206,6 @@ public class CollectionIdentifierDescriptorImpl implements CollectionIdentifierD
|
|||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int forEachSelectable(int offset, SelectableConsumer consumer) {
|
||||
consumer.accept( offset, this );
|
||||
return getJdbcTypeCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <X, Y> int breakDownJdbcValues(
|
||||
Object domainValue,
|
||||
|
|
|
@ -37,9 +37,6 @@ import org.hibernate.mapping.Property;
|
|||
import org.hibernate.mapping.Selectable;
|
||||
import org.hibernate.mapping.Value;
|
||||
import org.hibernate.metamodel.mapping.AttributeMapping;
|
||||
import org.hibernate.metamodel.mapping.DiscriminatorConverter;
|
||||
import org.hibernate.metamodel.mapping.DiscriminatorType;
|
||||
import org.hibernate.metamodel.mapping.EmbeddableDiscriminatorConverter;
|
||||
import org.hibernate.metamodel.mapping.EmbeddableDiscriminatorMapping;
|
||||
import org.hibernate.metamodel.mapping.EmbeddableMappingType;
|
||||
import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart;
|
||||
|
@ -57,7 +54,6 @@ import org.hibernate.metamodel.spi.EmbeddableInstantiator;
|
|||
import org.hibernate.metamodel.spi.EmbeddableRepresentationStrategy;
|
||||
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.property.access.spi.Getter;
|
||||
import org.hibernate.property.access.spi.PropertyAccess;
|
||||
import org.hibernate.spi.NavigablePath;
|
||||
import org.hibernate.sql.ast.tree.from.TableGroup;
|
||||
|
@ -77,16 +73,12 @@ import org.hibernate.type.descriptor.java.BasicPluralJavaType;
|
|||
import org.hibernate.type.descriptor.java.ImmutableMutabilityPlan;
|
||||
import org.hibernate.type.descriptor.java.JavaType;
|
||||
import org.hibernate.type.descriptor.java.MutabilityPlan;
|
||||
import org.hibernate.type.descriptor.java.spi.JavaTypeRegistry;
|
||||
import org.hibernate.type.descriptor.jdbc.AggregateJdbcType;
|
||||
import org.hibernate.type.descriptor.jdbc.JdbcTypeConstructor;
|
||||
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
||||
import org.hibernate.type.spi.CompositeTypeImplementor;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
import static org.hibernate.internal.util.StringHelper.qualify;
|
||||
import static org.hibernate.persister.entity.DiscriminatorHelper.getDiscriminatorType;
|
||||
|
||||
import static org.hibernate.type.SqlTypes.JSON;
|
||||
import static org.hibernate.type.SqlTypes.JSON_ARRAY;
|
||||
import static org.hibernate.type.SqlTypes.SQLXML;
|
||||
|
@ -461,8 +453,7 @@ public class EmbeddableMappingTypeImpl extends AbstractEmbeddableMapping impleme
|
|||
else {
|
||||
columnExpression = selectable.getText( dialect );
|
||||
}
|
||||
if ( selectable instanceof Column ) {
|
||||
final Column column = (Column) selectable;
|
||||
if ( selectable instanceof Column column ) {
|
||||
containingTableExpression = MappingModelCreationHelper.getTableIdentifierExpression(
|
||||
column.getValue().getTable(),
|
||||
creationProcess
|
||||
|
@ -485,8 +476,7 @@ public class EmbeddableMappingTypeImpl extends AbstractEmbeddableMapping impleme
|
|||
final Integer temporalPrecision;
|
||||
final boolean isLob;
|
||||
final boolean nullable;
|
||||
if ( selectable instanceof Column ) {
|
||||
final Column column = (Column) selectable;
|
||||
if ( selectable instanceof Column column ) {
|
||||
columnDefinition = column.getSqlType();
|
||||
length = column.getLength();
|
||||
precision = column.getPrecision();
|
||||
|
@ -537,9 +527,8 @@ public class EmbeddableMappingTypeImpl extends AbstractEmbeddableMapping impleme
|
|||
|
||||
columnPosition++;
|
||||
}
|
||||
else if ( subtype instanceof AnyType ) {
|
||||
else if ( subtype instanceof AnyType anyType ) {
|
||||
final Any bootValueMapping = (Any) value;
|
||||
final AnyType anyType = (AnyType) subtype;
|
||||
|
||||
final PropertyAccess propertyAccess = representationStrategy.resolvePropertyAccess( bootPropertyDescriptor );
|
||||
final boolean nullable = bootValueMapping.isNullable();
|
||||
|
@ -574,8 +563,7 @@ public class EmbeddableMappingTypeImpl extends AbstractEmbeddableMapping impleme
|
|||
creationProcess
|
||||
);
|
||||
}
|
||||
else if ( subtype instanceof CompositeType ) {
|
||||
final CompositeType subCompositeType = (CompositeType) subtype;
|
||||
else if ( subtype instanceof CompositeType subCompositeType ) {
|
||||
final int columnSpan = subCompositeType.getColumnSpan( creationProcess.getCreationContext().getMetadata() );
|
||||
final String subTableExpression;
|
||||
final String[] subRootTableKeyColumnNames;
|
||||
|
@ -928,8 +916,7 @@ public class EmbeddableMappingTypeImpl extends AbstractEmbeddableMapping impleme
|
|||
SharedSessionContractImplementor session) {
|
||||
final int size = attributeMappings.size();
|
||||
int span = 0;
|
||||
if ( domainValue instanceof Object[] ) {
|
||||
final Object[] values = (Object[]) domainValue;
|
||||
if ( domainValue instanceof Object[] values ) {
|
||||
assert values.length == size + ( isPolymorphic() ? 1 : 0 );
|
||||
int i = 0;
|
||||
for ( ; i < size; i++ ) {
|
||||
|
@ -1033,8 +1020,7 @@ public class EmbeddableMappingTypeImpl extends AbstractEmbeddableMapping impleme
|
|||
}
|
||||
final int size = attributeMappings.size();
|
||||
int span = 0;
|
||||
if ( domainValue instanceof Object[] ) {
|
||||
final Object[] values = (Object[]) domainValue;
|
||||
if ( domainValue instanceof Object[] values ) {
|
||||
assert values.length == size + ( isPolymorphic() ? 1 : 0 );
|
||||
int i = 0;
|
||||
for ( ; i < size; i++ ) {
|
||||
|
|
|
@ -114,11 +114,6 @@ public class EntityRowIdMappingImpl implements EntityRowIdMapping {
|
|||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getJdbcTypeCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JdbcMapping getJdbcMapping(int index) {
|
||||
if ( index != 0 ) {
|
||||
|
|
|
@ -76,8 +76,8 @@ public class ExplicitColumnDiscriminatorMappingImpl extends AbstractDiscriminato
|
|||
}
|
||||
|
||||
@Override
|
||||
public DiscriminatorType getMappedType() {
|
||||
return (DiscriminatorType) super.getMappedType();
|
||||
public DiscriminatorType<?> getMappedType() {
|
||||
return (DiscriminatorType<?>) super.getMappedType();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -170,6 +170,7 @@ public class SimpleForeignKeyDescriptor implements ForeignKeyDescriptor, BasicVa
|
|||
/*
|
||||
* Used by Hibernate Reactive
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
protected SimpleForeignKeyDescriptor(SimpleForeignKeyDescriptor original) {
|
||||
keySide = original.keySide;
|
||||
targetSide = original.targetSide;
|
||||
|
|
|
@ -245,7 +245,7 @@ public class AnonymousTupleBasicValuedModelPart implements OwnedValuedModelPart,
|
|||
}
|
||||
|
||||
@Override
|
||||
public BasicFetch generateFetch(
|
||||
public BasicFetch<?> generateFetch(
|
||||
FetchParent fetchParent,
|
||||
NavigablePath fetchablePath,
|
||||
FetchTiming fetchTiming,
|
||||
|
|
|
@ -24,7 +24,6 @@ import org.hibernate.bytecode.enhance.spi.interceptor.EnhancementHelper;
|
|||
import org.hibernate.bytecode.internal.BytecodeEnhancementMetadataNonPojoImpl;
|
||||
import org.hibernate.bytecode.internal.BytecodeEnhancementMetadataPojoImpl;
|
||||
import org.hibernate.bytecode.spi.BytecodeEnhancementMetadata;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.engine.OptimisticLockStyle;
|
||||
import org.hibernate.engine.spi.CascadeStyle;
|
||||
import org.hibernate.engine.spi.CascadeStyles;
|
||||
|
@ -477,8 +476,7 @@ public class EntityMetamodel implements Serializable {
|
|||
|
||||
private void verifyNaturalIdProperty(Property property) {
|
||||
final Value value = property.getValue();
|
||||
if ( value instanceof ManyToOne ) {
|
||||
final ManyToOne toOne = (ManyToOne) value;
|
||||
if ( value instanceof ManyToOne toOne ) {
|
||||
if ( toOne.getNotFoundAction() == NotFoundAction.IGNORE ) {
|
||||
throw new MappingException(
|
||||
"Attribute marked as natural-id can not also be a not-found association - "
|
||||
|
@ -486,8 +484,7 @@ public class EntityMetamodel implements Serializable {
|
|||
);
|
||||
}
|
||||
}
|
||||
else if ( value instanceof Component ) {
|
||||
final Component component = (Component) value;
|
||||
else if ( value instanceof Component component ) {
|
||||
for ( Property componentProperty : component.getProperties() ) {
|
||||
verifyNaturalIdProperty( componentProperty );
|
||||
}
|
||||
|
@ -514,10 +511,9 @@ public class EntityMetamodel implements Serializable {
|
|||
return generator;
|
||||
}
|
||||
}
|
||||
if ( mappingProperty.getValue() instanceof Component ) {
|
||||
final Dialect dialect = context.getDialect();
|
||||
final CompositeGeneratorBuilder builder = new CompositeGeneratorBuilder( entityName, mappingProperty, dialect );
|
||||
final Component component = (Component) mappingProperty.getValue();
|
||||
if ( mappingProperty.getValue() instanceof Component component ) {
|
||||
final CompositeGeneratorBuilder builder =
|
||||
new CompositeGeneratorBuilder( entityName, mappingProperty, context.getDialect() );
|
||||
for ( Property property : component.getProperties() ) {
|
||||
builder.add( property.createGenerator( context ) );
|
||||
}
|
||||
|
@ -536,8 +532,7 @@ public class EntityMetamodel implements Serializable {
|
|||
|
||||
private void mapPropertyToIndex(Property property, int i) {
|
||||
propertyIndexes.put( property.getName(), i );
|
||||
if ( property.getValue() instanceof Component ) {
|
||||
Component composite = (Component) property.getValue();
|
||||
if ( property.getValue() instanceof Component composite ) {
|
||||
for ( Property subproperty : composite.getProperties() ) {
|
||||
propertyIndexes.put(
|
||||
property.getName() + '.' + subproperty.getName(),
|
||||
|
@ -600,8 +595,7 @@ public class EntityMetamodel implements Serializable {
|
|||
}
|
||||
|
||||
private static boolean indicatesOwnedCollection(Type type, MetadataImplementor metadata) {
|
||||
if ( type instanceof CollectionType ) {
|
||||
final CollectionType collectionType = (CollectionType) type;
|
||||
if ( type instanceof CollectionType collectionType ) {
|
||||
return !metadata.getCollectionBinding( collectionType.getRole() ).isInverse();
|
||||
}
|
||||
else if ( type.isComponentType() ) {
|
||||
|
|
Loading…
Reference in New Issue