Remove DomainResultProducer NotYetImplementedFor6Exception

This commit is contained in:
Andrea Boriero 2021-10-06 16:31:19 +02:00 committed by Christian Beikov
parent 63c119bf89
commit 87c059ac95
27 changed files with 281 additions and 62 deletions

View File

@ -185,10 +185,7 @@ public interface SemanticQueryWalker<T> {
T visitDynamicInstantiation(SqmDynamicInstantiation<?> sqmDynamicInstantiation);
default T visitJpaCompoundSelection(SqmJpaCompoundSelection<?> selection) {
throw new NotYetImplementedFor6Exception( getClass() );
}
T visitJpaCompoundSelection(SqmJpaCompoundSelection<?> selection);
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// expressions - general

View File

@ -6,6 +6,10 @@
*/
package org.hibernate.query.sqm.function;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.BasicValuedMapping;
import org.hibernate.metamodel.mapping.MappingModelExpressable;
@ -17,15 +21,11 @@ import org.hibernate.query.sqm.sql.SqmToSqlAstConverter;
import org.hibernate.query.sqm.tree.SqmTypedNode;
import org.hibernate.query.sqm.tree.SqmVisitableNode;
import org.hibernate.query.sqm.tree.expression.SqmFunction;
import org.hibernate.query.sqm.tree.expression.SqmParameter;
import org.hibernate.sql.ast.tree.SqlAstNode;
import org.hibernate.sql.ast.tree.expression.Expression;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.type.spi.TypeConfiguration;
import java.util.ArrayList;
import java.util.List;
import static java.util.Collections.emptyList;
/**
@ -135,6 +135,13 @@ public class SelfRenderingSqmFunction<T> extends SqmFunction<T> {
return mapping;
}
@Override
public DomainResult<T> createDomainResult(
String resultVariable,
DomainResultCreationState creationState) {
throw new NotYetImplementedFor6Exception( getClass() );
}
@Override
public void applySqlSelections(DomainResultCreationState creationState) {
//implemented on SelfRenderingFunctionSqlAstExpression

View File

@ -8,7 +8,6 @@ package org.hibernate.query.sqm.sql.internal;
import org.hibernate.metamodel.mapping.ModelPart;
import org.hibernate.query.NavigablePath;
import org.hibernate.query.sqm.tree.domain.SqmPath;
import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;

View File

@ -6,13 +6,8 @@
*/
package org.hibernate.query.sqm.sql.internal;
import java.util.function.Consumer;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.type.spi.TypeConfiguration;
/**
* Something that can produce a DomainResult as part of a SQM interpretation
@ -46,11 +41,9 @@ public interface DomainResultProducer<T> {
/**
* Produce the domain query
*/
default DomainResult<T> createDomainResult(
DomainResult<T> createDomainResult(
String resultVariable,
DomainResultCreationState creationState) {
throw new NotYetImplementedFor6Exception( getClass() );
}
DomainResultCreationState creationState);
/**
* Used when this producer is a selection in a sub-query. The
@ -58,13 +51,5 @@ public interface DomainResultProducer<T> {
*
* This default impl assumes this producer is a true (Sql)Expression
*/
default void applySqlSelections(DomainResultCreationState creationState) {
throw new NotYetImplementedFor6Exception( getClass() );
// // this form works for basic-valued nodes
// creationState.getSqlExpressionResolver().resolveSqlSelection(
// (Expression) this,
// ( (Expression) this ).getType().getJavaTypeDescriptor(),
// creationState.getSqlAstCreationState().getCreationContext().getDomainModel().getTypeConfiguration()
// );
}
void applySqlSelections(DomainResultCreationState creationState);
}

View File

@ -19,8 +19,6 @@ import org.hibernate.query.spi.QueryParameterBinding;
import org.hibernate.query.spi.QueryParameterImplementor;
import org.hibernate.query.sqm.tree.expression.SqmParameter;
import org.hibernate.sql.ast.SqlAstWalker;
import org.hibernate.sql.ast.spi.SqlAstCreationState;
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
import org.hibernate.sql.ast.spi.SqlSelection;
import org.hibernate.sql.ast.tree.expression.Expression;
import org.hibernate.sql.ast.tree.expression.SqlTuple;

View File

@ -11,11 +11,8 @@ import java.util.Locale;
import org.hibernate.metamodel.model.domain.EntityDomainType;
import org.hibernate.metamodel.model.domain.SingularPersistentAttribute;
import org.hibernate.query.NavigablePath;
import org.hibernate.query.PathException;
import org.hibernate.query.hql.spi.SqmCreationProcessingState;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.SqmJoinable;
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.query.sqm.tree.from.SqmAttributeJoin;
import org.hibernate.query.sqm.tree.from.SqmFrom;
@ -23,7 +20,7 @@ import org.hibernate.query.sqm.tree.from.SqmFrom;
/**
* @author Steve Ebersole
*/
public class SqmSingularJoin<O,T> extends AbstractSqmAttributeJoin<O,T> implements DomainResultProducer<T> {
public class SqmSingularJoin<O,T> extends AbstractSqmAttributeJoin<O,T> {
public SqmSingularJoin(
SqmFrom<?,O> lhs,
SingularPersistentAttribute<O, T> joinedNavigable,

View File

@ -11,6 +11,8 @@ import org.hibernate.metamodel.mapping.MappingModelExpressable;
import org.hibernate.query.TemporalUnit;
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
import org.hibernate.sql.ast.SqlAstWalker;
import org.hibernate.sql.ast.spi.SqlAstCreationState;
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
import org.hibernate.sql.ast.tree.expression.Duration;
import org.hibernate.sql.ast.tree.expression.Expression;
import org.hibernate.sql.results.graph.DomainResult;
@ -68,6 +70,18 @@ public class Conversion
);
}
@Override
public void applySqlSelections(DomainResultCreationState creationState) {
final SqlAstCreationState sqlAstCreationState = creationState.getSqlAstCreationState();
final SqlExpressionResolver sqlExpressionResolver = sqlAstCreationState.getSqlExpressionResolver();
sqlExpressionResolver.resolveSqlSelection(
this,
type.getJdbcMapping().getJavaTypeDescriptor(),
sqlAstCreationState.getCreationContext().getDomainModel().getTypeConfiguration()
);
}
@Override
public MappingModelExpressable getExpressionType() {
return type;

View File

@ -6,6 +6,7 @@
*/
package org.hibernate.query.sqm.tree.expression;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.metamodel.model.domain.AllowableParameterType;
import org.hibernate.procedure.spi.NamedCallableQueryMemento;
import org.hibernate.query.ParameterMetadata;
@ -15,6 +16,8 @@ import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.SemanticQueryWalker;
import org.hibernate.query.sqm.SqmExpressable;
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
/**
* {@link JpaParameterExpression} created via JPA {@link jakarta.persistence.criteria.CriteriaBuilder}.
@ -159,4 +162,16 @@ public class JpaCriteriaParameter<T>
sb.append( getName() );
}
}
@Override
public DomainResult<T> createDomainResult(
String resultVariable,
DomainResultCreationState creationState) {
throw new NotYetImplementedFor6Exception( getClass() );
}
@Override
public void applySqlSelections(DomainResultCreationState creationState) {
throw new NotYetImplementedFor6Exception( getClass() );
}
}

View File

@ -8,16 +8,19 @@ package org.hibernate.query.sqm.tree.expression;
import java.util.ArrayList;
import java.util.List;
import jakarta.persistence.criteria.Expression;
import org.hibernate.query.criteria.JpaExpression;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.query.criteria.JpaSearchedCase;
import org.hibernate.query.internal.QueryHelper;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.SqmExpressable;
import org.hibernate.query.sqm.SemanticQueryWalker;
import org.hibernate.query.sqm.tree.predicate.SqmPredicate;
import org.hibernate.query.sqm.SqmExpressable;
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
import org.hibernate.query.sqm.tree.predicate.SqmPredicate;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import jakarta.persistence.criteria.Expression;
/**
* @author Steve Ebersole
@ -100,6 +103,18 @@ public class SqmCaseSearched<R>
return "<searched-case>";
}
@Override
public DomainResult<R> createDomainResult(
String resultVariable,
DomainResultCreationState creationState) {
throw new NotYetImplementedFor6Exception( getClass() );
}
@Override
public void applySqlSelections(DomainResultCreationState creationState) {
throw new NotYetImplementedFor6Exception( getClass() );
}
public static class WhenFragment<R> {
private final SqmPredicate predicate;
private final SqmExpression<R> result;

View File

@ -11,6 +11,7 @@ import java.util.List;
import jakarta.persistence.criteria.Expression;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.query.criteria.JpaExpression;
import org.hibernate.query.criteria.JpaSimpleCase;
import org.hibernate.query.internal.QueryHelper;
@ -18,6 +19,8 @@ import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.SqmExpressable;
import org.hibernate.query.sqm.SemanticQueryWalker;
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
/**
* @author Steve Ebersole
@ -107,6 +110,18 @@ public class SqmCaseSimple<T, R>
return "<simple-case>";
}
@Override
public DomainResult<R> createDomainResult(
String resultVariable,
DomainResultCreationState creationState) {
throw new NotYetImplementedFor6Exception( getClass() );
}
@Override
public void applySqlSelections(DomainResultCreationState creationState) {
throw new NotYetImplementedFor6Exception( getClass() );
}
public static class WhenFragment<T,R> {
private final SqmExpression<T> checkValue;
private final SqmExpression<R> result;

View File

@ -6,11 +6,14 @@
*/
package org.hibernate.query.sqm.tree.expression;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.SqmExpressable;
import org.hibernate.query.sqm.SemanticQueryWalker;
import org.hibernate.query.sqm.tree.domain.SqmPath;
import org.hibernate.query.sqm.SqmExpressable;
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
import org.hibernate.query.sqm.tree.domain.SqmPath;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.type.StandardBasicTypes;
/**
@ -52,15 +55,15 @@ public class SqmCollectionSize extends AbstractSqmExpression<Integer> implements
sb.append( ')' );
}
// @Override
// public DomainResult createDomainResult(
// String resultVariable,
// DomainResultCreationState creationState) {
// throw new NotYetImplementedFor6Exception( );
//// return new ScalarQueryResultImpl(
//// resultVariable,
//// creationContext.getSqlExpressionResolver().resolveSqlSelection( expression ),
//// getNodeType()
//// );
// }
@Override
public DomainResult<Integer> createDomainResult(
String resultVariable,
DomainResultCreationState creationState) {
throw new NotYetImplementedFor6Exception( getClass() );
}
@Override
public void applySqlSelections(DomainResultCreationState creationState) {
throw new NotYetImplementedFor6Exception( getClass() );
}
}

View File

@ -20,7 +20,6 @@ import org.hibernate.query.sqm.tree.domain.SqmPath;
import org.hibernate.query.sqm.tree.select.SqmSelectableNode;
import org.hibernate.sql.ast.tree.expression.Expression;
import java.util.ArrayList;
import java.util.List;
/**

View File

@ -6,11 +6,14 @@
*/
package org.hibernate.query.sqm.tree.expression;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.query.internal.QueryLiteralHelper;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.SemanticQueryWalker;
import org.hibernate.query.sqm.SqmExpressable;
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.type.descriptor.java.JavaType;
/**
@ -68,4 +71,16 @@ public class SqmLiteral<T>
}
}
@Override
public DomainResult<T> createDomainResult(
String resultVariable,
DomainResultCreationState creationState) {
throw new NotYetImplementedFor6Exception( getClass() );
}
@Override
public void applySqlSelections(DomainResultCreationState creationState) {
throw new NotYetImplementedFor6Exception( getClass() );
}
}

View File

@ -11,14 +11,16 @@ import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.query.DynamicInstantiationNature;
import org.hibernate.query.criteria.JpaCompoundSelection;
import org.hibernate.query.criteria.JpaSelection;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.SemanticQueryWalker;
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
import org.hibernate.query.sqm.tree.expression.SqmExpression;
import org.hibernate.query.sqm.tree.jpa.AbstractJpaSelection;
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.type.descriptor.java.JavaType;
import org.jboss.logging.Logger;
@ -70,7 +72,7 @@ public class SqmDynamicInstantiation<T>
public static <M extends Map<?, ?>> SqmDynamicInstantiation<M> forMapInstantiation(NodeBuilder nodeBuilder) {
//noinspection unchecked
return (SqmDynamicInstantiation<M>) (SqmDynamicInstantiation<?>) forMapInstantiation(
return forMapInstantiation(
nodeBuilder.getTypeConfiguration().getJavaTypeDescriptorRegistry().getDescriptor( Map.class ),
nodeBuilder
);
@ -87,7 +89,7 @@ public class SqmDynamicInstantiation<T>
public static <L extends List<?>> SqmDynamicInstantiation<L> forListInstantiation(NodeBuilder nodeBuilder) {
//noinspection unchecked
return (SqmDynamicInstantiation<L>) (SqmDynamicInstantiation<?>) forListInstantiation(
return forListInstantiation(
nodeBuilder.getTypeConfiguration().getJavaTypeDescriptorRegistry().getDescriptor( List.class ),
nodeBuilder
);
@ -198,6 +200,18 @@ public class SqmDynamicInstantiation<T>
return new SqmDynamicInstantiation<>( getInstantiationTarget(), nodeBuilder() );
}
@Override
public DomainResult<T> createDomainResult(
String resultVariable,
DomainResultCreationState creationState) {
throw new NotYetImplementedFor6Exception( getClass() );
}
@Override
public void applySqlSelections(DomainResultCreationState creationState) {
throw new NotYetImplementedFor6Exception( getClass() );
}
private static class DynamicInstantiationTargetImpl<T> implements SqmDynamicInstantiationTarget<T> {
private final DynamicInstantiationNature nature;
private final JavaType<T> javaTypeDescriptor;

View File

@ -11,6 +11,7 @@ import java.util.function.Consumer;
import jakarta.persistence.criteria.Selection;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.query.criteria.JpaCompoundSelection;
import org.hibernate.query.criteria.JpaSelection;
import org.hibernate.query.sqm.NodeBuilder;
@ -18,6 +19,8 @@ import org.hibernate.query.sqm.SqmExpressable;
import org.hibernate.query.sqm.SemanticQueryWalker;
import org.hibernate.query.sqm.tree.expression.AbstractSqmExpression;
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.type.descriptor.java.JavaType;
/**
@ -123,4 +126,16 @@ public class SqmJpaCompoundSelection<T>
public void visitSubSelectableNodes(Consumer<SqmSelectableNode<?>> jpaSelectionConsumer) {
selectableNodes.forEach( jpaSelectionConsumer );
}
@Override
public DomainResult<T> createDomainResult(
String resultVariable,
DomainResultCreationState creationState) {
throw new NotYetImplementedFor6Exception( getClass() );
}
@Override
public void applySqlSelections(DomainResultCreationState creationState) {
throw new NotYetImplementedFor6Exception( getClass() );
}
}

View File

@ -9,6 +9,8 @@ package org.hibernate.sql.ast.tree.expression;
import org.hibernate.metamodel.mapping.MappingModelExpressable;
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
import org.hibernate.sql.ast.SqlAstWalker;
import org.hibernate.sql.ast.spi.SqlAstCreationState;
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
import org.hibernate.sql.ast.tree.select.QueryPart;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
@ -57,4 +59,16 @@ public class Any implements Expression, DomainResultProducer {
javaTypeDescriptor
);
}
@Override
public void applySqlSelections(DomainResultCreationState creationState) {
final SqlAstCreationState sqlAstCreationState = creationState.getSqlAstCreationState();
final SqlExpressionResolver sqlExpressionResolver = sqlAstCreationState.getSqlExpressionResolver();
sqlExpressionResolver.resolveSqlSelection(
this,
type.getJdbcMappings().get( 0 ).getJavaTypeDescriptor(),
sqlAstCreationState.getCreationContext().getDomainModel().getTypeConfiguration()
);
}
}

View File

@ -7,10 +7,7 @@
package org.hibernate.sql.ast.tree.expression;
import org.hibernate.metamodel.mapping.BasicValuedMapping;
import org.hibernate.metamodel.model.domain.AllowableParameterType;
import org.hibernate.query.BinaryArithmeticOperator;
import org.hibernate.query.SemanticException;
import org.hibernate.query.spi.QueryParameterBinding;
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
import org.hibernate.sql.ast.SqlAstWalker;
import org.hibernate.sql.ast.spi.SqlSelection;

View File

@ -16,6 +16,7 @@ import org.hibernate.metamodel.mapping.BasicValuedModelPart;
import org.hibernate.metamodel.mapping.MappingModelExpressable;
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
import org.hibernate.sql.ast.SqlAstWalker;
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
import org.hibernate.sql.ast.spi.SqlSelection;
import org.hibernate.sql.ast.tree.predicate.Predicate;
import org.hibernate.sql.results.graph.DomainResult;
@ -83,6 +84,26 @@ public class CaseSearchedExpression implements Expression, DomainResultProducer
);
}
@Override
public void applySqlSelections(DomainResultCreationState creationState) {
final SqlExpressionResolver sqlExpressionResolver = creationState.getSqlAstCreationState()
.getSqlExpressionResolver();
final SqlSelection sqlSelection = sqlExpressionResolver
.resolveSqlSelection(
this,
type.getExpressableJavaTypeDescriptor(),
creationState.getSqlAstCreationState()
.getCreationContext()
.getSessionFactory()
.getTypeConfiguration()
);
sqlExpressionResolver.resolveSqlSelection(
this,
type.getExpressableJavaTypeDescriptor(),
creationState.getSqlAstCreationState().getCreationContext().getDomainModel().getTypeConfiguration()
);
}
@Override
public void accept(SqlAstWalker walker) {
walker.visitCaseSearchedExpression( this );

View File

@ -14,6 +14,8 @@ import java.util.List;
import org.hibernate.metamodel.mapping.MappingModelExpressable;
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
import org.hibernate.sql.ast.SqlAstWalker;
import org.hibernate.sql.ast.spi.SqlAstCreationState;
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.sql.results.graph.basic.BasicResult;
@ -71,6 +73,18 @@ public class CaseSimpleExpression implements Expression, DomainResultProducer {
);
}
@Override
public void applySqlSelections(DomainResultCreationState creationState) {
final SqlAstCreationState sqlAstCreationState = creationState.getSqlAstCreationState();
final SqlExpressionResolver sqlExpressionResolver = sqlAstCreationState.getSqlExpressionResolver();
sqlExpressionResolver.resolveSqlSelection(
this,
type.getJdbcMappings().get( 0 ).getJavaTypeDescriptor(),
sqlAstCreationState.getCreationContext().getDomainModel().getTypeConfiguration()
);
}
public List<WhenFragment> getWhenFragments() {
return whenFragments;
}

View File

@ -12,6 +12,8 @@ import org.hibernate.metamodel.mapping.JdbcMappingContainer;
import org.hibernate.metamodel.mapping.SqlExpressable;
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
import org.hibernate.sql.ast.SqlAstWalker;
import org.hibernate.sql.ast.spi.SqlAstCreationState;
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
import org.hibernate.sql.ast.tree.SqlAstNode;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
@ -84,6 +86,18 @@ public class Collate implements Expression, SqlExpressable, SqlAstNode, DomainRe
);
}
@Override
public void applySqlSelections(DomainResultCreationState creationState) {
final SqlAstCreationState sqlAstCreationState = creationState.getSqlAstCreationState();
final SqlExpressionResolver sqlExpressionResolver = sqlAstCreationState.getSqlExpressionResolver();
sqlExpressionResolver.resolveSqlSelection(
this,
expression.getExpressionType().getJdbcMappings().get( 0 ).getJavaTypeDescriptor(),
sqlAstCreationState.getCreationContext().getDomainModel().getTypeConfiguration()
);
}
@Override
public int forEachJdbcType(int offset, IndexedConsumer<JdbcMapping> action) {
action.accept( offset, getJdbcMapping() );

View File

@ -9,7 +9,10 @@ package org.hibernate.sql.ast.tree.expression;
import org.hibernate.metamodel.mapping.BasicValuedMapping;
import org.hibernate.query.TemporalUnit;
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
import org.hibernate.query.sqm.tree.expression.Conversion;
import org.hibernate.sql.ast.SqlAstWalker;
import org.hibernate.sql.ast.spi.SqlAstCreationState;
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.sql.results.graph.basic.BasicResult;
@ -65,6 +68,18 @@ public class Duration implements Expression, DomainResultProducer {
);
}
@Override
public void applySqlSelections(DomainResultCreationState creationState) {
final SqlAstCreationState sqlAstCreationState = creationState.getSqlAstCreationState();
final SqlExpressionResolver sqlExpressionResolver = sqlAstCreationState.getSqlExpressionResolver();
sqlExpressionResolver.resolveSqlSelection(
this,
type.getJdbcMapping().getJavaTypeDescriptor(),
sqlAstCreationState.getCreationContext().getDomainModel().getTypeConfiguration()
);
}
@Override
public BasicValuedMapping getExpressionType() {
return type;

View File

@ -9,6 +9,9 @@ package org.hibernate.sql.ast.tree.expression;
import org.hibernate.metamodel.mapping.MappingModelExpressable;
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
import org.hibernate.sql.ast.SqlAstWalker;
import org.hibernate.sql.ast.spi.SqlAstCreationState;
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
import org.hibernate.sql.ast.tree.select.QueryGroup;
import org.hibernate.sql.ast.tree.select.QueryPart;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
@ -57,4 +60,16 @@ public class Every implements Expression, DomainResultProducer {
javaTypeDescriptor
);
}
@Override
public void applySqlSelections(DomainResultCreationState creationState) {
final SqlAstCreationState sqlAstCreationState = creationState.getSqlAstCreationState();
final SqlExpressionResolver sqlExpressionResolver = sqlAstCreationState.getSqlExpressionResolver();
sqlExpressionResolver.resolveSqlSelection(
this,
type.getJdbcMappings().get( 0 ).getJavaTypeDescriptor(),
sqlAstCreationState.getCreationContext().getDomainModel().getTypeConfiguration()
);
}
}

View File

@ -10,6 +10,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.metamodel.mapping.MappingModelExpressable;
import org.hibernate.query.sqm.SqmExpressable;
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
@ -79,6 +80,11 @@ public class SqlTuple implements Expression, SqlTupleContainer, DomainResultProd
);
}
@Override
public void applySqlSelections(DomainResultCreationState creationState) {
throw new NotYetImplementedFor6Exception( getClass() );
}
public static class Builder {
private final MappingModelExpressable valueMapping;

View File

@ -13,6 +13,8 @@ import org.hibernate.metamodel.mapping.MappingModelExpressable;
import org.hibernate.query.UnaryArithmeticOperator;
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
import org.hibernate.sql.ast.SqlAstWalker;
import org.hibernate.sql.ast.spi.SqlAstCreationState;
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
import org.hibernate.sql.ast.spi.SqlSelection;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
@ -72,7 +74,14 @@ public class UnaryOperation implements Expression, DomainResultProducer {
@Override
public void applySqlSelections(DomainResultCreationState creationState) {
throw new NotYetImplementedFor6Exception( getClass() );
final SqlAstCreationState sqlAstCreationState = creationState.getSqlAstCreationState();
final SqlExpressionResolver sqlExpressionResolver = sqlAstCreationState.getSqlExpressionResolver();
sqlExpressionResolver.resolveSqlSelection(
this,
type.getJdbcMapping().getJavaTypeDescriptor(),
sqlAstCreationState.getCreationContext().getDomainModel().getTypeConfiguration()
);
}
}

View File

@ -7,14 +7,14 @@
package org.hibernate.sql.ast.tree.from;
import org.hibernate.query.NavigablePath;
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
import org.hibernate.sql.ast.SqlAstJoinType;
import org.hibernate.sql.ast.spi.SqlAstTreeHelper;
import org.hibernate.sql.ast.SqlAstWalker;
import org.hibernate.sql.ast.spi.SqlAstTreeHelper;
import org.hibernate.sql.ast.tree.SqlAstNode;
import org.hibernate.sql.ast.tree.predicate.Predicate;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
/**
* @author Steve Ebersole
@ -86,4 +86,9 @@ public class TableGroupJoin implements TableJoin, DomainResultProducer {
DomainResultCreationState creationState) {
return getJoinedGroup().createDomainResult( resultVariable, creationState );
}
@Override
public void applySqlSelections(DomainResultCreationState creationState) {
getJoinedGroup().applySqlSelections( creationState );
}
}

View File

@ -46,4 +46,16 @@ public interface Predicate extends Expression, DomainResultProducer<Boolean> {
//noinspection unchecked
return new BasicResult( sqlSelection.getValuesArrayPosition(), resultVariable, javaTypeDescriptor );
}
@Override
default void applySqlSelections(DomainResultCreationState creationState) {
final SqlAstCreationState sqlAstCreationState = creationState.getSqlAstCreationState();
final SqlExpressionResolver sqlExpressionResolver = sqlAstCreationState.getSqlExpressionResolver();
sqlExpressionResolver.resolveSqlSelection(
this,
getExpressionType().getJdbcMappings().get( 0 ).getJavaTypeDescriptor(),
sqlAstCreationState.getCreationContext().getDomainModel().getTypeConfiguration()
);
}
}

View File

@ -11,9 +11,12 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.query.DynamicInstantiationNature;
import org.hibernate.query.sqm.sql.ConversionException;
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
import org.hibernate.sql.ast.spi.SqlAstCreationState;
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.type.descriptor.java.JavaType;
@ -116,6 +119,12 @@ public class DynamicInstantiation<T> implements DomainResultProducer {
.collect( Collectors.toList() )
);
}
@Override
public void applySqlSelections(DomainResultCreationState creationState) {
throw new NotYetImplementedFor6Exception( getClass() );
}
//
// @SuppressWarnings("unchecked")
// private static DomainResultAssembler resolveAssembler(