From 230a8190655dcb8b2d54c59cd31deee8f7bc2b84 Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Thu, 11 Jul 2019 09:58:57 +0100 Subject: [PATCH] 6 - SQM based on JPA type system --- .../model/domain/AllowableParameterType.java | 6 ++++ .../persister/entity/PropertyMapping.java | 6 ++++ .../BinaryArithmeticExpression.java | 32 +++++++++---------- .../sql/results/spi/DomainResultProducer.java | 6 ++-- 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/AllowableParameterType.java b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/AllowableParameterType.java index 3f88c1cf9e..d5a12f5f90 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/AllowableParameterType.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/AllowableParameterType.java @@ -7,8 +7,10 @@ package org.hibernate.metamodel.model.domain; import org.hibernate.Incubating; +import org.hibernate.NotYetImplementedFor6Exception; import org.hibernate.metamodel.model.mapping.spi.Writeable; import org.hibernate.query.Query; +import org.hibernate.type.descriptor.java.JavaTypeDescriptor; /** * Specialization of DomainType for types that can be used as {@link Query} parameter bind values @@ -23,4 +25,8 @@ import org.hibernate.query.Query; */ @Incubating public interface AllowableParameterType extends Writeable { + + default JavaTypeDescriptor getExpressableJavaTypeDescriptor(){ + throw new NotYetImplementedFor6Exception( getClass() ); + } } diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/PropertyMapping.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/PropertyMapping.java index 10763bd7f1..a5aca3e5b0 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/PropertyMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/PropertyMapping.java @@ -8,6 +8,7 @@ package org.hibernate.persister.entity; import org.hibernate.NotYetImplementedFor6Exception; import org.hibernate.QueryException; +import org.hibernate.annotations.Remove; import org.hibernate.metamodel.model.domain.DomainType; import org.hibernate.persister.SqlExpressableType; import org.hibernate.type.Type; @@ -74,4 +75,9 @@ public interface PropertyMapping { * Given a property path, return the corresponding column name(s). */ public String[] toColumns(String propertyName) throws QueryException, UnsupportedOperationException; + /** + * Get the type of the thing containing the properties + */ + @Remove + public Type getType(); } diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/BinaryArithmeticExpression.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/BinaryArithmeticExpression.java index 6f58c270d8..50603cf0fd 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/BinaryArithmeticExpression.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/BinaryArithmeticExpression.java @@ -71,22 +71,22 @@ public class BinaryArithmeticExpression walker.visitBinaryArithmeticExpression( this ); } - @Override - public DomainResult createDomainResult( - String resultVariable, - DomainResultCreationState creationState) { - final SqlSelection sqlSelection = creationState.getSqlExpressionResolver().resolveSqlSelection( - this, - getType().getJavaTypeDescriptor(), - creationState.getSqlAstCreationState().getCreationContext().getDomainModel().getTypeConfiguration() - ); - //noinspection unchecked - return new ScalarDomainResultImpl( - sqlSelection.getValuesArrayPosition(), - resultVariable, - resultType.getJavaTypeDescriptor() - ); - } +// @Override +// public DomainResult createDomainResult( +// String resultVariable, +// DomainResultCreationState creationState) { +// final SqlSelection sqlSelection = creationState.getSqlExpressionResolver().resolveSqlSelection( +// this, +// getType().getJavaTypeDescriptor(), +// creationState.getSqlAstCreationState().getCreationContext().getDomainModel().getTypeConfiguration() +// ); +// //noinspection unchecked +// return new ScalarDomainResultImpl( +// sqlSelection.getValuesArrayPosition(), +// resultVariable, +// resultType.getJavaTypeDescriptor() +// ); +// } /** * Get the left-hand operand. diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/DomainResultProducer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/spi/DomainResultProducer.java index 4b8b693e78..0941ca7e79 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/DomainResultProducer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/spi/DomainResultProducer.java @@ -19,10 +19,12 @@ public interface DomainResultProducer { /** * Produce the domain query */ - DomainResult createDomainResult( + default DomainResult createDomainResult( int valuesArrayPosition, String resultVariable, - DomainResultCreationState creationState); + DomainResultCreationState creationState){ + throw new NotYetImplementedFor6Exception( getClass() ); + } /** * Used when this producer is a selection in a sub-query. The