From ee11f9a9ef1e7af26dd6892c8f3bb8a2877f5daa Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Wed, 6 Oct 2021 12:27:45 +0200 Subject: [PATCH] Remove Bindable NotYetImplementedFor6Exception --- .../hibernate/metamodel/mapping/Bindable.java | 11 +++------ .../internal/AnyDiscriminatorPart.java | 11 +++++++++ .../mapping/internal/AnyKeyPart.java | 15 ++++++++++++ .../BasicEntityIdentifierMappingImpl.java | 10 ++++++++ .../CollectionIdentifierDescriptorImpl.java | 15 ++++++++++++ .../internal/DiscriminatedCollectionPart.java | 22 ++++++++++++++++++ .../internal/EntityRowIdMappingImpl.java | 16 +++++++++++++ .../internal/EntityVersionMappingImpl.java | 16 +++++++++++++ .../internal/PluralAttributeMappingImpl.java | 23 +++++++++---------- .../CircularBiDirectionalFetchImpl.java | 16 +++++++++++++ .../internal/domain/CircularFetchImpl.java | 16 +++++++++++++ 11 files changed, 151 insertions(+), 20 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/Bindable.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/Bindable.java index f142b8bb93..bdddab3ae0 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/Bindable.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/Bindable.java @@ -10,7 +10,6 @@ import java.util.ArrayList; import java.util.List; import org.hibernate.Incubating; -import org.hibernate.NotYetImplementedFor6Exception; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.mapping.IndexedConsumer; import org.hibernate.sql.ast.Clause; @@ -115,9 +114,7 @@ public interface Bindable extends JdbcMappingContainer { * Note that the identifier is not part of this disassembled state. Note also * how the embedded value results in a sub-array. */ - default Object disassemble(Object value, SharedSessionContractImplementor session) { - throw new NotYetImplementedFor6Exception( getClass() ); - } + Object disassemble(Object value, SharedSessionContractImplementor session); /** * @asciidoc @@ -143,14 +140,12 @@ public interface Bindable extends JdbcMappingContainer { return forEachDisassembledJdbcValue( value, clause, 0, valuesConsumer, session ); } - default int forEachDisassembledJdbcValue( + int forEachDisassembledJdbcValue( Object value, Clause clause, int offset, JdbcValuesConsumer valuesConsumer, - SharedSessionContractImplementor session) { - throw new NotYetImplementedFor6Exception( getClass() ); - } + SharedSessionContractImplementor session); /** * Visit each constituent JDBC value extracted from the entity instance itself. diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AnyDiscriminatorPart.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AnyDiscriminatorPart.java index ed469f3861..e3f0f7125e 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AnyDiscriminatorPart.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AnyDiscriminatorPart.java @@ -24,6 +24,7 @@ import org.hibernate.metamodel.mapping.SelectableConsumer; import org.hibernate.metamodel.mapping.SelectableMapping; import org.hibernate.metamodel.model.domain.NavigableRole; import org.hibernate.query.NavigablePath; +import org.hibernate.sql.ast.Clause; import org.hibernate.sql.ast.spi.FromClauseAccess; import org.hibernate.sql.ast.spi.SqlAstCreationState; import org.hibernate.sql.ast.spi.SqlExpressionResolver; @@ -143,6 +144,16 @@ public class AnyDiscriminatorPart implements BasicValuedModelPart, FetchOptions, return discriminator; } + @Override + public int forEachDisassembledJdbcValue( + Object value, + Clause clause, + int offset, + JdbcValuesConsumer valuesConsumer, + SharedSessionContractImplementor session) { + throw new NotYetImplementedFor6Exception( getClass() ); + } + @Override public void breakDownJdbcValues(Object domainValue, JdbcValueConsumer valueConsumer, SharedSessionContractImplementor session) { valueConsumer.consume( domainValue, this ); diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AnyKeyPart.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AnyKeyPart.java index e87270d09a..7c9ae6fb42 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AnyKeyPart.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AnyKeyPart.java @@ -227,6 +227,21 @@ public class AnyKeyPart implements BasicValuedModelPart, FetchOptions { return Collections.singletonList( jdbcMapping ); } + @Override + public Object disassemble(Object value, SharedSessionContractImplementor session) { + return anyPart.disassemble( value, session ); + } + + @Override + public int forEachDisassembledJdbcValue( + Object value, + Clause clause, + int offset, + JdbcValuesConsumer valuesConsumer, + SharedSessionContractImplementor session) { + return anyPart.forEachDisassembledJdbcValue( value, clause, offset, valuesConsumer, session ); + } + @Override public DomainResult createDomainResult( NavigablePath navigablePath, diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/BasicEntityIdentifierMappingImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/BasicEntityIdentifierMappingImpl.java index 0fbb1205d8..f7d3e64f73 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/BasicEntityIdentifierMappingImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/BasicEntityIdentifierMappingImpl.java @@ -319,6 +319,16 @@ public class BasicEntityIdentifierMappingImpl implements BasicEntityIdentifierMa // return propertyAccess.getGetter().get( value ); } + @Override + public int forEachDisassembledJdbcValue( + Object value, + Clause clause, + int offset, + JdbcValuesConsumer valuesConsumer, + SharedSessionContractImplementor session) { + return idType.forEachDisassembledJdbcValue( value, clause, offset, valuesConsumer, session ); + } + @Override public Fetch generateFetch( FetchParent fetchParent, diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/CollectionIdentifierDescriptorImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/CollectionIdentifierDescriptorImpl.java index d8d1f99d50..fff64f9b4c 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/CollectionIdentifierDescriptorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/CollectionIdentifierDescriptorImpl.java @@ -18,6 +18,7 @@ import org.hibernate.metamodel.mapping.MappingType; import org.hibernate.metamodel.model.domain.NavigableRole; import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.query.NavigablePath; +import org.hibernate.sql.ast.Clause; import org.hibernate.sql.ast.spi.FromClauseAccess; import org.hibernate.sql.ast.spi.SqlAstCreationContext; import org.hibernate.sql.ast.spi.SqlAstCreationState; @@ -253,4 +254,18 @@ public class CollectionIdentifierDescriptorImpl implements CollectionIdentifierD return FetchTiming.IMMEDIATE; } + @Override + public Object disassemble(Object value, SharedSessionContractImplementor session) { + return type.disassemble( value, session ); + } + + @Override + public int forEachDisassembledJdbcValue( + Object value, + Clause clause, + int offset, + JdbcValuesConsumer valuesConsumer, + SharedSessionContractImplementor session) { + return type.forEachDisassembledJdbcValue( value, clause, offset, valuesConsumer, session ); + } } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/DiscriminatedCollectionPart.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/DiscriminatedCollectionPart.java index 78a951c7c5..534b214a69 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/DiscriminatedCollectionPart.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/DiscriminatedCollectionPart.java @@ -28,6 +28,7 @@ import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator; import org.hibernate.sql.ast.spi.SqlAstCreationContext; import org.hibernate.sql.ast.spi.SqlExpressionResolver; import org.hibernate.sql.ast.tree.from.StandardVirtualTableGroup; +import org.hibernate.sql.ast.Clause; import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.ast.tree.from.TableGroupJoin; import org.hibernate.sql.ast.tree.predicate.Predicate; @@ -188,6 +189,27 @@ public class DiscriminatedCollectionPart implements DiscriminatedAssociationMode return getDiscriminatorPart().getJdbcTypeCount() + getKeyPart().getJdbcTypeCount(); } + @Override + public Object disassemble(Object value, SharedSessionContractImplementor session) { + return discriminatorMapping.getDiscriminatorPart().disassemble( value, session ); + } + + @Override + public int forEachDisassembledJdbcValue( + Object value, + Clause clause, + int offset, + JdbcValuesConsumer valuesConsumer, + SharedSessionContractImplementor session) { + return discriminatorMapping.getDiscriminatorPart().forEachDisassembledJdbcValue( + value, + clause, + offset, + valuesConsumer, + session + ); + } + @Override public void breakDownJdbcValues(Object domainValue, JdbcValueConsumer valueConsumer, SharedSessionContractImplementor session) { discriminatorMapping.getDiscriminatorPart().breakDownJdbcValues( domainValue, valueConsumer, session ); diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EntityRowIdMappingImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EntityRowIdMappingImpl.java index 75584bb19f..8d54b00c00 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EntityRowIdMappingImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EntityRowIdMappingImpl.java @@ -17,6 +17,7 @@ import org.hibernate.metamodel.mapping.MappingType; import org.hibernate.metamodel.mapping.SelectableMapping; import org.hibernate.metamodel.model.domain.NavigableRole; import org.hibernate.query.NavigablePath; +import org.hibernate.sql.ast.Clause; import org.hibernate.sql.ast.spi.SqlAstCreationState; import org.hibernate.sql.ast.spi.SqlExpressionResolver; import org.hibernate.sql.ast.spi.SqlSelection; @@ -121,6 +122,21 @@ public class EntityRowIdMappingImpl implements EntityRowIdMapping, SelectableMap return 1; } + @Override + public Object disassemble(Object value, SharedSessionContractImplementor session) { + return rowIdType.disassemble( value, session ); + } + + @Override + public int forEachDisassembledJdbcValue( + Object value, + Clause clause, + int offset, + JdbcValuesConsumer valuesConsumer, + SharedSessionContractImplementor session) { + return rowIdType.forEachDisassembledJdbcValue( value, clause, offset, valuesConsumer, session ); + } + @Override public int forEachJdbcType(int offset, IndexedConsumer action) { action.accept( offset, getJdbcMapping() ); diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EntityVersionMappingImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EntityVersionMappingImpl.java index 89eea69abc..b52119bcaf 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EntityVersionMappingImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EntityVersionMappingImpl.java @@ -22,6 +22,7 @@ import org.hibernate.metamodel.mapping.JdbcMapping; import org.hibernate.metamodel.mapping.MappingType; import org.hibernate.metamodel.model.domain.NavigableRole; import org.hibernate.query.NavigablePath; +import org.hibernate.sql.ast.Clause; import org.hibernate.sql.ast.spi.SqlAstCreationState; import org.hibernate.sql.ast.spi.SqlExpressionResolver; import org.hibernate.sql.ast.spi.SqlSelection; @@ -279,4 +280,19 @@ public class EntityVersionMappingImpl implements EntityVersionMapping, FetchOpti public FetchTiming getTiming() { return FetchTiming.IMMEDIATE; } + + @Override + public Object disassemble(Object value, SharedSessionContractImplementor session) { + return versionBasicType.disassemble( value, session ); + } + + @Override + public int forEachDisassembledJdbcValue( + Object value, + Clause clause, + int offset, + JdbcValuesConsumer valuesConsumer, + SharedSessionContractImplementor session) { + return versionBasicType.forEachDisassembledJdbcValue( value, clause, offset, valuesConsumer, session ); + } } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/PluralAttributeMappingImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/PluralAttributeMappingImpl.java index 562e1c6889..ff73ec2f98 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/PluralAttributeMappingImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/PluralAttributeMappingImpl.java @@ -41,6 +41,7 @@ import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.entity.Joinable; import org.hibernate.property.access.spi.PropertyAccess; import org.hibernate.query.NavigablePath; +import org.hibernate.sql.ast.Clause; import org.hibernate.sql.ast.SqlAstJoinType; import org.hibernate.sql.ast.spi.FromClauseAccess; import org.hibernate.sql.ast.spi.SqlAliasBase; @@ -781,18 +782,6 @@ public class PluralAttributeMappingImpl } } - @Override - public TableGroup createRootTableGroup( - boolean canUseInnerJoins, - NavigablePath navigablePath, - String explicitSourceAlias, - Supplier> additionalPredicateCollectorAccess, - SqlAliasBase sqlAliasBase, - SqlAstCreationState creationState, - SqlAstCreationContext creationContext) { - throw new NotYetImplementedFor6Exception( getClass() ); - } - @Override public boolean isAffectedByEnabledFilters(LoadQueryInfluencers influencers) { return getCollectionDescriptor().isAffectedByEnabledFilters( influencers ); @@ -887,6 +876,16 @@ public class PluralAttributeMappingImpl return elementDescriptor.disassemble( value,session ); } + @Override + public int forEachDisassembledJdbcValue( + Object value, + Clause clause, + int offset, + JdbcValuesConsumer valuesConsumer, + SharedSessionContractImplementor session) { + return elementDescriptor.forEachDisassembledJdbcValue( value, clause, offset, valuesConsumer, session ); + } + @Override public int getNumberOfFetchables() { return indexDescriptor == null ? 1 : 2; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/CircularBiDirectionalFetchImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/CircularBiDirectionalFetchImpl.java index 669233b72e..9df9344edd 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/CircularBiDirectionalFetchImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/CircularBiDirectionalFetchImpl.java @@ -25,6 +25,7 @@ import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.UniqueKeyLoadable; import org.hibernate.proxy.HibernateProxy; import org.hibernate.query.NavigablePath; +import org.hibernate.sql.ast.Clause; import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.results.graph.AssemblerCreationState; import org.hibernate.sql.results.graph.BiDirectionalFetch; @@ -181,6 +182,21 @@ public class CircularBiDirectionalFetchImpl implements BiDirectionalFetch, Assoc throw new UnsupportedOperationException(); } + @Override + public Object disassemble(Object value, SharedSessionContractImplementor session) { + throw new UnsupportedOperationException(); + } + + @Override + public int forEachDisassembledJdbcValue( + Object value, + Clause clause, + int offset, + JdbcValuesConsumer valuesConsumer, + SharedSessionContractImplementor session) { + throw new UnsupportedOperationException(); + } + private static class CircularFetchAssembler implements DomainResultAssembler { private final NavigablePath circularPath; private final JavaType javaTypeDescriptor; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/CircularFetchImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/CircularFetchImpl.java index e37aa7b2e3..fa152c43b5 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/CircularFetchImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/CircularFetchImpl.java @@ -17,6 +17,7 @@ import org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping; import org.hibernate.metamodel.model.domain.NavigableRole; import org.hibernate.persister.entity.EntityPersister; import org.hibernate.query.NavigablePath; +import org.hibernate.sql.ast.Clause; import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.results.graph.AssemblerCreationState; import org.hibernate.sql.results.graph.BiDirectionalFetch; @@ -237,6 +238,21 @@ public class CircularFetchImpl implements BiDirectionalFetch, Association { throw new UnsupportedOperationException(); } + @Override + public Object disassemble(Object value, SharedSessionContractImplementor session) { + throw new UnsupportedOperationException(); + } + + @Override + public int forEachDisassembledJdbcValue( + Object value, + Clause clause, + int offset, + JdbcValuesConsumer valuesConsumer, + SharedSessionContractImplementor session) { + throw new UnsupportedOperationException(); + } + private static class BiDirectionalFetchAssembler implements DomainResultAssembler { private EntityInitializer initializer; private JavaType assembledJavaTypeDescriptor;