6 - SQM based on JPA type system

- Initial work on SQL AST generation based on older persister model
This commit is contained in:
Steve Ebersole 2019-08-05 19:12:41 -05:00 committed by Andrea Boriero
parent 4dd7c280ca
commit bb207c0926
146 changed files with 651 additions and 572 deletions

View File

@ -39,8 +39,7 @@ import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.query.spi.QueryEngine;
import org.hibernate.query.spi.QueryParameterBindingTypeResolver;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.produce.spi.SqmCreationContext;
import org.hibernate.query.sqm.spi.SqmCreationContext;
import org.hibernate.service.spi.ServiceRegistryImplementor;
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
import org.hibernate.stat.spi.StatisticsImplementor;

View File

@ -22,7 +22,6 @@ public class NaturalIdLoaderStandardImpl<T> implements NaturalIdLoader<T> {
}
@Override
@SuppressWarnings("unchecked")
public EntityPersister getLoadable() {
return entityDescriptor;
}

View File

@ -18,7 +18,7 @@ import org.hibernate.metamodel.model.mapping.spi.ModelPart;
*
* @author Steve Ebersole
*/
public interface Loadable<T> extends ModelPart<T> {
public interface Loadable extends ModelPart {
boolean isAffectedByEnabledFilters(LoadQueryInfluencers influencers);
boolean isAffectedByEntityGraph(LoadQueryInfluencers influencers);
boolean isAffectedByEnabledFetchProfiles(LoadQueryInfluencers influencers);

View File

@ -11,9 +11,9 @@ package org.hibernate.loader.spi;
*
* @author Steve Ebersole
*/
public interface Loader<T> {
public interface Loader {
/**
* The value-mapping loaded by this loader
*/
Loadable<T> getLoadable();
Loadable getLoadable();
}

View File

@ -17,9 +17,8 @@ import org.hibernate.persister.entity.MultiLoadOptions;
*
* @author Steve Ebersole
*/
public interface MultiIdEntityLoader<T> extends Loader<T> {
public interface MultiIdEntityLoader<T> extends Loader {
@Override
@SuppressWarnings("unchecked")
EntityPersister getLoadable();
List<T> load(Object[] ids, MultiLoadOptions options, SharedSessionContractImplementor session);

View File

@ -14,7 +14,7 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor;
*
* @author Steve Ebersole
*/
public interface NaturalIdLoader<T> extends Loader<T> {
public interface NaturalIdLoader<T> extends Loader {
interface LoadOptions {
/**
* The locking options for the loaded entity

View File

@ -15,9 +15,8 @@ import org.hibernate.persister.entity.EntityPersister;
*
* @author Steve Ebersole
*/
public interface SingleEntityLoader<T> extends Loader<T> {
public interface SingleEntityLoader<T> extends Loader {
@Override
@SuppressWarnings("unchecked")
EntityPersister getLoadable();
/**

View File

@ -7,19 +7,22 @@
package org.hibernate.metamodel.model.domain;
import org.hibernate.Incubating;
import org.hibernate.metamodel.model.mapping.spi.ModelPart;
import org.hibernate.metamodel.model.mapping.spi.ValueMapping;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.metamodel.model.mapping.spi.Writeable;
import org.hibernate.query.Query;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
import org.hibernate.type.spi.TypeConfiguration;
/**
* Specialization of DomainType for types that can be used as {@link Query} parameter bind values.
*
* todo (6.0) : Need a resolution between AllowableParameterType and {@link ValueMapping} / {@link ModelPart}
*
* @author Steve Ebersole
*/
@Incubating
public interface AllowableParameterType<J> extends SimpleDomainType<J> {
JavaTypeDescriptor<J> getExpressableJavaTypeDescriptor();
default Writeable resolveWriteable(TypeConfiguration typeConfiguration) {
throw new NotYetImplementedFor6Exception( getClass() );
}
}

View File

@ -6,6 +6,8 @@
*/
package org.hibernate.metamodel.model.domain;
import org.hibernate.metamodel.model.mapping.spi.Writeable;
/**
* Describes any non-collection type
*

View File

@ -14,7 +14,7 @@ import org.hibernate.metamodel.model.domain.PluralPersistentAttribute;
import org.hibernate.metamodel.model.domain.SimpleDomainType;
import org.hibernate.query.NavigablePath;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.query.sqm.tree.domain.SqmPath;
import org.hibernate.query.sqm.tree.domain.SqmPluralValuedSimplePath;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;

View File

@ -8,9 +8,8 @@ package org.hibernate.metamodel.model.domain.internal;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.metamodel.model.domain.AnyMappingDomainType;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.query.sqm.tree.domain.SqmPath;
/**

View File

@ -11,7 +11,7 @@ import java.util.Collection;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.metamodel.model.domain.BagPersistentAttribute;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.query.sqm.tree.domain.SqmBagJoin;
import org.hibernate.query.sqm.tree.from.SqmAttributeJoin;

View File

@ -12,7 +12,7 @@ import org.hibernate.metamodel.model.domain.BasicDomainType;
import org.hibernate.query.NavigablePath;
import org.hibernate.query.sqm.IllegalPathUsageException;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.query.sqm.tree.domain.SqmBasicValuedSimplePath;
import org.hibernate.query.sqm.tree.domain.SqmPath;

View File

@ -9,7 +9,7 @@ package org.hibernate.metamodel.model.domain.internal;
import org.hibernate.metamodel.model.domain.AllowableParameterType;
import org.hibernate.metamodel.model.domain.EmbeddableDomainType;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.query.sqm.tree.domain.SqmEmbeddedValuedSimplePath;
import org.hibernate.query.sqm.tree.domain.SqmPath;

View File

@ -10,9 +10,8 @@ import org.hibernate.metamodel.model.domain.EntityDomainType;
import org.hibernate.metamodel.model.domain.PersistentAttribute;
import org.hibernate.metamodel.model.domain.SingularPersistentAttribute;
import org.hibernate.query.SemanticException;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.query.sqm.tree.domain.SqmEntityValuedSimplePath;
import org.hibernate.query.sqm.tree.domain.SqmPath;

View File

@ -19,7 +19,7 @@ import org.hibernate.metamodel.model.domain.JpaMetamodel;
import org.hibernate.metamodel.model.domain.PersistentAttribute;
import org.hibernate.metamodel.model.domain.SingularPersistentAttribute;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.query.sqm.tree.domain.SqmPath;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;

View File

@ -10,7 +10,7 @@ import java.util.List;
import org.hibernate.metamodel.model.domain.ListPersistentAttribute;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.query.sqm.tree.domain.SqmListJoin;
import org.hibernate.query.sqm.tree.from.SqmAttributeJoin;

View File

@ -12,7 +12,7 @@ import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.metamodel.model.domain.MapPersistentAttribute;
import org.hibernate.metamodel.model.domain.SimpleDomainType;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.query.sqm.tree.domain.SqmMapJoin;
import org.hibernate.query.sqm.tree.from.SqmAttributeJoin;

View File

@ -9,7 +9,7 @@ package org.hibernate.metamodel.model.domain.internal;
import java.util.Set;
import org.hibernate.metamodel.model.domain.SetPersistentAttribute;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.query.sqm.tree.domain.SqmSetJoin;
import org.hibernate.query.sqm.tree.from.SqmAttributeJoin;

View File

@ -16,7 +16,7 @@ import org.hibernate.metamodel.model.domain.ManagedDomainType;
import org.hibernate.metamodel.model.domain.SimpleDomainType;
import org.hibernate.metamodel.model.domain.SingularPersistentAttribute;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.query.sqm.tree.domain.SqmPath;
import org.hibernate.query.sqm.tree.domain.SqmSingularJoin;

View File

@ -21,11 +21,12 @@ import org.hibernate.sql.results.spi.DomainResultProducer;
*
* @author Steve Ebersole
*/
public interface ModelPart<T> extends Readable, Writeable {
public interface ModelPart {
/**
* Create a DomainResult for a specific reference to this ModelPart.
*/
default DomainResult<T> createDomainResult(
default <T> DomainResult<T> createDomainResult(
NavigablePath navigablePath,
int valuesArrayPosition,
String resultVariable,
@ -41,4 +42,9 @@ public interface ModelPart<T> extends Readable, Writeable {
DomainResultCreationState creationState) {
throw new NotYetImplementedFor6Exception( getClass() );
}
default Writeable getWriteable() {
// todo (6.0) : or in-line
throw new NotYetImplementedFor6Exception( getClass() );
}
}

View File

@ -1,57 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.metamodel.model.mapping.spi;
import java.util.function.Consumer;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.persister.SqlExpressableType;
import org.hibernate.query.NavigablePath;
import org.hibernate.sql.results.spi.DomainResult;
import org.hibernate.sql.results.spi.DomainResultCreationState;
import org.hibernate.type.spi.TypeConfiguration;
/**
* Contract for things at the domain/mapping level that can be extracted from a JDBC result
*
* Really, reading/loading stuff is defined via {@link DomainResult} and
* {@link org.hibernate.sql.results.spi.Initializer}. This contract simply works as a sort
* of extended `DomainResultProducer` specifically for mapped-parts of a domain model
*
* @author Steve Ebersole
*/
public interface Readable {
/**
* Visit all of the SqlExpressableTypes associated with this this Readable.
*
* Used during cacheable SQL AST creation.
*/
default void visitJdbcTypes(Consumer<SqlExpressableType> action, TypeConfiguration typeConfiguration) {
throw new NotYetImplementedFor6Exception( getClass() );
}
/**
* Create a DomainResult for a specific reference to this ModelPart.
*/
default DomainResult<?> createDomainResult(
NavigablePath navigablePath,
int valuesArrayPosition,
String resultVariable,
DomainResultCreationState creationState) {
throw new NotYetImplementedFor6Exception( getClass() );
}
/**
* Apply SQL selections for a specific reference to this ModelPart outside the domain query's root select clause.
*/
default void applySqlSelections(
NavigablePath navigablePath,
DomainResultCreationState creationState) {
throw new NotYetImplementedFor6Exception( getClass() );
}
}

View File

@ -21,7 +21,7 @@ import org.hibernate.type.Type;
*
* @author Steve Ebersole
*/
public interface ValueMapping<D> extends ModelPart<D> {
public interface ValueMapping extends ModelPart {
/**
* Get the Type associated with this mapping

View File

@ -15,18 +15,18 @@ import org.hibernate.NotYetImplementedFor6Exception;
*
* @author Steve Ebersole
*/
public interface ValueMappingContainer<D> extends ModelPart<D> {
public interface ValueMappingContainer extends ModelPart {
/**
* Find a sub-ValueMapping by name
*/
default <X> ValueMapping<X> findValueMapping(String name){
default ValueMapping findValueMapping(String name){
throw new NotYetImplementedFor6Exception( getClass() );
}
/**
* Visit all of this container's sub-ValueMappings
*/
default void visitValueMappings(Consumer<ValueMapping<?>> consumer){
default void visitValueMappings(Consumer<ValueMapping> consumer){
throw new NotYetImplementedFor6Exception( getClass() );
}

View File

@ -14,8 +14,8 @@ import org.hibernate.query.hql.spi.SemanticPathPart;
import org.hibernate.query.hql.spi.SqmPathRegistry;
import org.hibernate.query.sqm.ParsingException;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.produce.spi.SqmCreationContext;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationContext;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.query.sqm.tree.domain.SqmPath;
import org.hibernate.query.sqm.tree.expression.SqmEnumLiteral;
import org.hibernate.query.sqm.tree.expression.SqmExpression;

View File

@ -10,7 +10,7 @@ import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.query.SemanticException;
import org.hibernate.query.hql.spi.SemanticPathPart;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.query.sqm.tree.domain.SqmPath;
import org.hibernate.query.sqm.tree.expression.SqmExpression;

View File

@ -7,7 +7,7 @@
package org.hibernate.query.hql.internal;
import org.hibernate.query.hql.spi.SemanticPathPart;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.query.sqm.tree.domain.SqmPath;
import org.hibernate.query.sqm.tree.expression.SqmExpression;

View File

@ -12,7 +12,6 @@ import java.math.BigInteger;
import java.util.Collection;
import java.util.List;
import java.util.function.Function;
import javax.persistence.criteria.Expression;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
@ -22,13 +21,14 @@ import org.hibernate.query.criteria.JpaSelection;
import org.hibernate.query.hql.HqlInterpretationException;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.SqmExpressable;
import org.hibernate.query.sqm.consume.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.query.sqm.tree.expression.SqmEnumLiteral;
import org.hibernate.query.sqm.tree.expression.SqmExpression;
import org.hibernate.query.sqm.tree.expression.SqmFieldLiteral;
import org.hibernate.query.sqm.tree.expression.SqmLiteralEntityType;
import org.hibernate.query.sqm.tree.predicate.SqmPredicate;
import org.hibernate.sql.results.spi.DomainResultProducer;
import org.hibernate.type.descriptor.java.EnumJavaTypeDescriptor;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
@ -239,4 +239,9 @@ public class FullyQualifiedReflectivePathTerminal
public NodeBuilder nodeBuilder() {
return null;
}
@Override
public DomainResultProducer getDomainResultProducer() {
throw new UnsupportedOperationException( );
}
}

View File

@ -14,8 +14,8 @@ import org.hibernate.query.hql.spi.SemanticPathPart;
import org.hibernate.query.hql.spi.SqmPathRegistry;
import org.hibernate.query.sqm.SqmJoinable;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.produce.spi.SqmCreationProcessingState;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationProcessingState;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.query.sqm.tree.domain.SqmPolymorphicRootDescriptor;
import org.hibernate.query.sqm.tree.from.SqmAttributeJoin;

View File

@ -10,10 +10,9 @@ import java.util.Locale;
import org.hibernate.query.SemanticException;
import org.hibernate.query.hql.spi.SemanticPathPart;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.query.sqm.tree.from.SqmFrom;
import org.hibernate.query.sqm.tree.from.SqmQualifiedJoin;
import org.hibernate.query.sqm.tree.from.SqmRoot;
/**
* Specialized consumer for processing domain model paths occurring as part

View File

@ -14,12 +14,12 @@ import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.internal.util.collections.Stack;
import org.hibernate.metamodel.model.domain.EntityDomainType;
import org.hibernate.query.NavigablePath;
import org.hibernate.query.sqm.consume.spi.BaseSemanticQueryWalker;
import org.hibernate.query.sqm.produce.spi.SqmCreationProcessingState;
import org.hibernate.query.sqm.spi.BaseSemanticQueryWalker;
import org.hibernate.query.sqm.spi.SqmCreationProcessingState;
import org.hibernate.query.hql.spi.SqmPathRegistry;
import org.hibernate.query.sqm.produce.spi.SqmCreationContext;
import org.hibernate.query.sqm.produce.spi.SqmCreationOptions;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationContext;
import org.hibernate.query.sqm.spi.SqmCreationOptions;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.query.sqm.tree.delete.SqmDeleteStatement;
import org.hibernate.query.sqm.tree.domain.SqmBasicValuedSimplePath;
import org.hibernate.query.sqm.tree.domain.SqmEmbeddedValuedSimplePath;

View File

@ -55,18 +55,16 @@ import org.hibernate.query.sqm.function.SqmExtractUnit;
import org.hibernate.query.sqm.function.SqmStar;
import org.hibernate.query.sqm.function.SqmTrimSpecification;
import org.hibernate.query.sqm.internal.ParameterCollector;
import org.hibernate.query.sqm.produce.SqmTreeCreationLogger;
import org.hibernate.query.sqm.spi.SqmTreeCreationLogger;
import org.hibernate.query.sqm.produce.function.SqmFunctionTemplate;
import org.hibernate.query.sqm.produce.function.spi.NamedSqmFunctionTemplate;
import org.hibernate.query.sqm.produce.internal.SqmDmlCreationProcessingState;
import org.hibernate.query.sqm.produce.internal.SqmQuerySpecCreationProcessingStateStandardImpl;
import org.hibernate.query.sqm.produce.internal.UniqueIdGenerator;
import org.hibernate.query.sqm.produce.spi.ImplicitAliasGenerator;
import org.hibernate.query.sqm.produce.spi.ParameterDeclarationContext;
import org.hibernate.query.sqm.produce.spi.SqmCreationContext;
import org.hibernate.query.sqm.produce.spi.SqmCreationOptions;
import org.hibernate.query.sqm.produce.spi.SqmCreationProcessingState;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.internal.SqmDmlCreationProcessingState;
import org.hibernate.query.sqm.internal.SqmQuerySpecCreationProcessingStateStandardImpl;
import org.hibernate.query.sqm.spi.ParameterDeclarationContext;
import org.hibernate.query.sqm.spi.SqmCreationContext;
import org.hibernate.query.sqm.spi.SqmCreationOptions;
import org.hibernate.query.sqm.spi.SqmCreationProcessingState;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.query.sqm.tree.SqmStatement;
import org.hibernate.query.sqm.tree.SqmTypedNode;

View File

@ -9,9 +9,9 @@ package org.hibernate.query.hql.internal;
import org.hibernate.QueryException;
import org.hibernate.query.sqm.InterpretationException;
import org.hibernate.query.hql.SemanticQueryProducer;
import org.hibernate.query.sqm.produce.internal.SqmTreePrinter;
import org.hibernate.query.sqm.produce.spi.SqmCreationContext;
import org.hibernate.query.sqm.produce.spi.SqmCreationOptions;
import org.hibernate.query.sqm.internal.SqmTreePrinter;
import org.hibernate.query.sqm.spi.SqmCreationContext;
import org.hibernate.query.sqm.spi.SqmCreationOptions;
import org.hibernate.query.sqm.tree.SqmStatement;
/**

View File

@ -18,8 +18,8 @@ import org.hibernate.query.hql.spi.SqmPathRegistry;
import org.hibernate.query.sqm.AliasCollisionException;
import org.hibernate.query.sqm.ParsingException;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.produce.spi.SqmCreationProcessingState;
import org.hibernate.query.sqm.produce.SqmTreeCreationLogger;
import org.hibernate.query.sqm.spi.SqmCreationProcessingState;
import org.hibernate.query.sqm.spi.SqmTreeCreationLogger;
import org.hibernate.query.sqm.tree.domain.SqmPath;
import org.hibernate.query.sqm.tree.from.SqmFrom;
import org.hibernate.query.sqm.tree.select.SqmSelection;

View File

@ -6,7 +6,7 @@
*/
package org.hibernate.query.hql.spi;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.query.sqm.tree.domain.SqmPath;
import org.hibernate.query.sqm.tree.expression.SqmExpression;
import org.hibernate.query.sqm.tree.domain.SqmSimplePath;

View File

@ -24,9 +24,9 @@ import org.hibernate.query.sqm.internal.SqmCriteriaNodeBuilder;
import org.hibernate.query.hql.SemanticQueryProducer;
import org.hibernate.query.sqm.produce.function.SqmFunctionRegistry;
import org.hibernate.query.hql.internal.SemanticQueryProducerImpl ;
import org.hibernate.query.sqm.produce.internal.SqmCreationOptionsStandard;
import org.hibernate.query.sqm.produce.spi.SqmCreationContext;
import org.hibernate.query.sqm.produce.spi.SqmCreationOptions;
import org.hibernate.query.sqm.internal.SqmCreationOptionsStandard;
import org.hibernate.query.sqm.spi.SqmCreationContext;
import org.hibernate.query.sqm.spi.SqmCreationOptions;
import org.hibernate.service.ServiceRegistry;
/**

View File

@ -6,7 +6,7 @@
*/
package org.hibernate.query.sqm;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.query.sqm.tree.from.SqmAttributeJoin;
import org.hibernate.query.sqm.tree.from.SqmFrom;

View File

@ -10,7 +10,7 @@ import java.util.Locale;
import javax.persistence.metamodel.Bindable;
import org.hibernate.metamodel.model.domain.DomainType;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.query.sqm.tree.domain.SqmPath;
/**

View File

@ -1,22 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
/**
*
* <p/>
* Once you have received a {@link org.hibernate.query.sqm.tree.SqmStatement} from
* SemanticQueryInterpreter you can:<ul>
* <li>
* "Split" it (if it is a {@link org.hibernate.query.sqm.tree.select.SqmSelectStatement})
* using {@link org.hibernate.query.hql.internal.QuerySplitter}
* </li>
* <li>
* Create a walker/visitor for it using {@link org.hibernate.query.sqm.consume.spi.BaseSemanticQueryWalker}
* </li>
* </ul>
*/
package org.hibernate.query.sqm.consume;

View File

@ -1,21 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.query.sqm.consume.spi;
import org.hibernate.loader.spi.AfterLoadAction;
/**
* Callback to allow SQM interpretation to trigger certain things within ORM. See the current
* {@link AfterLoadAction} javadocs for details. Specifically this would
* encompass things like follow-on locking, follow-on fetching, etc.
*
* @author Steve Ebersole
*/
public interface Callback {
void registerAfterLoadAction(AfterLoadAction afterLoadAction);
}

View File

@ -9,7 +9,7 @@ package org.hibernate.query.sqm.function;
import org.hibernate.metamodel.model.domain.AllowableFunctionReturnType;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.SqmExpressable;
import org.hibernate.query.sqm.consume.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.tree.AbstractSqmNode;
import org.hibernate.query.sqm.tree.SqmTypedNode;
import org.hibernate.query.sqm.tree.SqmVisitableNode;

View File

@ -15,10 +15,11 @@ import org.hibernate.metamodel.model.domain.AllowableFunctionReturnType;
import org.hibernate.query.criteria.JpaCoalesce;
import org.hibernate.query.criteria.JpaExpression;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.consume.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.produce.function.SqmFunctionTemplate;
import org.hibernate.query.sqm.tree.expression.AbstractSqmExpression;
import org.hibernate.query.sqm.tree.expression.SqmExpression;
import org.hibernate.sql.results.spi.DomainResultProducer;
/**
* Specialized CASE statement for resolving the first non-null value in a list of values
@ -26,7 +27,7 @@ import org.hibernate.query.sqm.tree.expression.SqmExpression;
* @author Steve Ebersole
* @author Gavin King
*/
public class SqmCoalesce<T> extends AbstractSqmExpression<T> implements JpaCoalesce<T> {
public class SqmCoalesce<T> extends AbstractSqmExpression<T> implements JpaCoalesce<T>, DomainResultProducer<T> {
private List<SqmExpression<? extends T>> arguments = new ArrayList<>();
private SqmFunctionTemplate coalesceFunction;
@ -102,4 +103,8 @@ public class SqmCoalesce<T> extends AbstractSqmExpression<T> implements JpaCoale
return this;
}
@Override
public DomainResultProducer<T> getDomainResultProducer() {
return this;
}
}

View File

@ -8,7 +8,7 @@ package org.hibernate.query.sqm.function;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.SqmExpressable;
import org.hibernate.query.sqm.consume.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.tree.AbstractSqmNode;
import org.hibernate.query.sqm.tree.SqmTypedNode;
import org.hibernate.query.sqm.tree.SqmVisitableNode;

View File

@ -9,7 +9,7 @@ package org.hibernate.query.sqm.function;
import org.hibernate.metamodel.model.domain.AllowableFunctionReturnType;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.SqmExpressable;
import org.hibernate.query.sqm.consume.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.tree.AbstractSqmNode;
import org.hibernate.query.sqm.tree.SqmTypedNode;
import org.hibernate.query.sqm.tree.SqmVisitableNode;

View File

@ -7,8 +7,9 @@
package org.hibernate.query.sqm.function;
import org.hibernate.query.criteria.JpaFunction;
import org.hibernate.query.sqm.consume.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.tree.expression.SqmExpression;
import org.hibernate.sql.results.spi.DomainResultProducer;
/**
* Contract for functions impls that would like to control the
@ -20,7 +21,7 @@ import org.hibernate.query.sqm.tree.expression.SqmExpression;
*
* @author Steve Ebersole
*/
public interface SqmFunction<T> extends SqmExpression<T>, JpaFunction<T> {
public interface SqmFunction<T> extends SqmExpression<T>, JpaFunction<T>, DomainResultProducer<T> {
// /**
// * Generate the SQL AST form of the function as an expression.
// *
@ -35,4 +36,9 @@ public interface SqmFunction<T> extends SqmExpression<T>, JpaFunction<T> {
default <X> X accept(SemanticQueryWalker<X> walker) {
return walker.visitFunction( this );
}
@Override
default DomainResultProducer<T> getDomainResultProducer() {
return this;
}
}

View File

@ -7,8 +7,9 @@
package org.hibernate.query.sqm.function;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.consume.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.tree.expression.AbstractSqmExpression;
import org.hibernate.sql.results.spi.DomainResultProducer;
/**
* @author Gavin King
@ -23,4 +24,9 @@ public class SqmStar extends AbstractSqmExpression<Object> {
public <X> X accept(SemanticQueryWalker<X> walker) {
return walker.visitStar(this);
}
@Override
public DomainResultProducer<Object> getDomainResultProducer() {
throw new UnsupportedOperationException( );
}
}

View File

@ -9,7 +9,7 @@ package org.hibernate.query.sqm.function;
import org.hibernate.query.TrimSpec;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.SqmExpressable;
import org.hibernate.query.sqm.consume.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.tree.AbstractSqmNode;
import org.hibernate.query.sqm.tree.SqmTypedNode;
import org.hibernate.query.sqm.tree.SqmVisitableNode;

View File

@ -4,10 +4,10 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.query.sqm.produce.internal;
package org.hibernate.query.sqm.internal;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.query.sqm.produce.spi.SqmCreationOptions;
import org.hibernate.query.sqm.spi.SqmCreationOptions;
/**
* @author Steve Ebersole

View File

@ -4,12 +4,12 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.query.sqm.produce.internal;
package org.hibernate.query.sqm.internal;
import org.hibernate.query.hql.internal.SqmPathRegistryImpl;
import org.hibernate.query.sqm.produce.spi.SqmCreationProcessingState;
import org.hibernate.query.sqm.spi.SqmCreationProcessingState;
import org.hibernate.query.hql.spi.SqmPathRegistry;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.query.sqm.tree.SqmQuery;
/**

View File

@ -4,9 +4,9 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.query.sqm.produce.internal;
package org.hibernate.query.sqm.internal;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.query.sqm.tree.SqmQuery;
/**

View File

@ -4,11 +4,11 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.query.sqm.produce.internal;
package org.hibernate.query.sqm.internal;
import org.hibernate.query.sqm.produce.spi.SqmCreationProcessingState;
import org.hibernate.query.sqm.produce.spi.SqmQuerySpecCreationProcessingState;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationProcessingState;
import org.hibernate.query.sqm.spi.SqmQuerySpecCreationProcessingState;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.query.sqm.tree.select.SqmSelectQuery;
import org.hibernate.query.sqm.tree.select.SqmSelection;

View File

@ -4,13 +4,13 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.query.sqm.produce.internal;
package org.hibernate.query.sqm.internal;
import java.util.Locale;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.query.QueryLogger;
import org.hibernate.query.sqm.consume.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.tree.SqmStatement;
import org.hibernate.query.sqm.tree.delete.SqmDeleteStatement;
import org.hibernate.query.sqm.tree.domain.SqmBasicValuedSimplePath;

View File

@ -10,15 +10,17 @@ import java.util.List;
import org.hibernate.metamodel.model.domain.AllowableFunctionReturnType;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.function.SqmFunction;
import org.hibernate.query.sqm.produce.function.spi.SelfRenderingFunctionSupport;
import org.hibernate.query.sqm.tree.SqmTypedNode;
import org.hibernate.query.sqm.tree.expression.AbstractSqmExpression;
import org.hibernate.query.sqm.function.SqmFunction;
/**
* @author Steve Ebersole
*/
public class SelfRenderingSqmFunction<T> extends AbstractSqmExpression<T> implements SqmFunction<T> {
public class SelfRenderingSqmFunction<T>
extends AbstractSqmExpression<T>
implements SqmFunction<T> {
private final String name;
private final SelfRenderingFunctionSupport renderingSupport;
private final List<SqmTypedNode<?>> arguments;

View File

@ -1,35 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.query.sqm.produce.spi;
/**
* Handles generating implicit (or synthetic) aliases.
*
* @author Steve Ebersole
*/
public class ImplicitAliasGenerator {
private int unAliasedCount = 0;
/**
* Builds a unique implicit alias.
*
* @return The generated alias.
*/
public synchronized String generateUniqueImplicitAlias() {
return "<gen:" + unAliasedCount++ + ">";
}
/**
* Determine if the given alias is implicit.
*
* @param alias The alias to check
* @return True/false.
*/
public static boolean isImplicitAlias(String alias) {
return alias == null || ( alias.startsWith( "<gen:" ) && alias.endsWith( ">" ) );
}
}

View File

@ -4,9 +4,15 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.query.sqm.consume.spi;
package org.hibernate.query.sqm.spi;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.query.sqm.function.SqmCastTarget;
import org.hibernate.query.sqm.function.SqmDistinct;
import org.hibernate.query.sqm.function.SqmExtractUnit;
import org.hibernate.query.sqm.function.SqmFunction;
import org.hibernate.query.sqm.function.SqmStar;
import org.hibernate.query.sqm.function.SqmTrimSpecification;
import org.hibernate.query.sqm.tree.delete.SqmDeleteStatement;
import org.hibernate.query.sqm.tree.domain.SqmBasicValuedSimplePath;
import org.hibernate.query.sqm.tree.domain.SqmCorrelation;
@ -37,17 +43,10 @@ import org.hibernate.query.sqm.tree.expression.SqmPositionalParameter;
import org.hibernate.query.sqm.tree.expression.SqmRestrictedSubQueryExpression;
import org.hibernate.query.sqm.tree.expression.SqmTuple;
import org.hibernate.query.sqm.tree.expression.SqmUnaryOperation;
import org.hibernate.query.sqm.function.SqmCastTarget;
import org.hibernate.query.sqm.function.SqmDistinct;
import org.hibernate.query.sqm.function.SqmExtractUnit;
import org.hibernate.query.sqm.function.SqmFunction;
import org.hibernate.query.sqm.function.SqmStar;
import org.hibernate.query.sqm.function.SqmTrimSpecification;
import org.hibernate.query.sqm.tree.from.SqmAttributeJoin;
import org.hibernate.query.sqm.tree.from.SqmCrossJoin;
import org.hibernate.query.sqm.tree.from.SqmEntityJoin;
import org.hibernate.query.sqm.tree.from.SqmFromClause;
import org.hibernate.query.sqm.tree.from.SqmJoin;
import org.hibernate.query.sqm.tree.from.SqmRoot;
import org.hibernate.query.sqm.tree.insert.SqmInsertSelectStatement;
import org.hibernate.query.sqm.tree.predicate.SqmAndPredicate;
@ -80,10 +79,11 @@ import org.hibernate.query.sqm.tree.update.SqmUpdateStatement;
import org.hibernate.service.ServiceRegistry;
/**
* Base support for an SQM walker
*
* @author Steve Ebersole
*/
@SuppressWarnings("unchecked")
public class BaseSemanticQueryWalker<T> implements SemanticQueryWalker<T> {
public class BaseSemanticQueryWalker implements SemanticQueryWalker<Object> {
private final ServiceRegistry serviceRegistry;
public BaseSemanticQueryWalker(ServiceRegistry serviceRegistry) {
@ -95,145 +95,145 @@ public class BaseSemanticQueryWalker<T> implements SemanticQueryWalker<T> {
}
@Override
public T visitSelectStatement(SqmSelectStatement<?> statement) {
public Object visitSelectStatement(SqmSelectStatement<?> statement) {
visitQuerySpec( statement.getQuerySpec() );
return (T) statement;
return statement;
}
@Override
public T visitUpdateStatement(SqmUpdateStatement<?> statement) {
public Object visitUpdateStatement(SqmUpdateStatement<?> statement) {
visitRootPath( statement.getTarget() );
visitSetClause( statement.getSetClause() );
visitWhereClause( statement.getWhereClause() );
return (T) statement;
return statement;
}
@Override
public T visitSetClause(SqmSetClause setClause) {
public Object visitSetClause(SqmSetClause setClause) {
for ( SqmAssignment assignment : setClause.getAssignments() ) {
visitAssignment( assignment );
}
return (T) setClause;
return setClause;
}
@Override
public T visitAssignment(SqmAssignment assignment) {
public Object visitAssignment(SqmAssignment assignment) {
assignment.getTargetPath().accept( this );
assignment.getValue().accept( this );
return (T) assignment;
return assignment;
}
@Override
public T visitInsertSelectStatement(SqmInsertSelectStatement<?> statement) {
public Object visitInsertSelectStatement(SqmInsertSelectStatement<?> statement) {
visitRootPath( statement.getTarget() );
for ( SqmPath<?> stateField : statement.getInsertionTargetPaths() ) {
stateField.accept( this );
}
visitQuerySpec( statement.getSelectQuerySpec() );
return (T) statement;
return statement;
}
@Override
public T visitDeleteStatement(SqmDeleteStatement<?> statement) {
public Object visitDeleteStatement(SqmDeleteStatement<?> statement) {
visitRootPath( statement.getTarget() );
visitWhereClause( statement.getWhereClause() );
return (T) statement;
return statement;
}
@Override
public T visitQuerySpec(SqmQuerySpec querySpec) {
public Object visitQuerySpec(SqmQuerySpec querySpec) {
visitFromClause( querySpec.getFromClause() );
visitSelectClause( querySpec.getSelectClause() );
visitWhereClause( querySpec.getWhereClause() );
visitOrderByClause( querySpec.getOrderByClause() );
visitOffsetExpression( querySpec.getOffsetExpression() );
visitLimitExpression( querySpec.getLimitExpression() );
return (T) querySpec;
return querySpec;
}
@Override
public T visitFromClause(SqmFromClause fromClause) {
public Object visitFromClause(SqmFromClause fromClause) {
fromClause.visitRoots( this::visitRootPath );
return (T) fromClause;
return fromClause;
}
@Override
public T visitRootPath(SqmRoot<?> sqmRoot) {
sqmRoot.visitSqmJoins( sqmJoin -> ( (SqmJoin) sqmJoin ).accept( this ) );
return (T) sqmRoot;
public Object visitRootPath(SqmRoot<?> sqmRoot) {
sqmRoot.visitSqmJoins( sqmJoin -> sqmJoin.accept( this ) );
return sqmRoot;
}
@Override
public T visitCrossJoin(SqmCrossJoin<?> joinedFromElement) {
public Object visitCrossJoin(SqmCrossJoin<?> joinedFromElement) {
joinedFromElement.visitSqmJoins( sqmJoin -> sqmJoin.accept( this ) );
return (T) joinedFromElement;
return joinedFromElement;
}
@Override
public T visitQualifiedEntityJoin(SqmEntityJoin<?> joinedFromElement) {
public Object visitQualifiedEntityJoin(SqmEntityJoin<?> joinedFromElement) {
joinedFromElement.visitSqmJoins( sqmJoin -> sqmJoin.accept( this ) );
return (T) joinedFromElement;
return joinedFromElement;
}
@Override
public T visitQualifiedAttributeJoin(SqmAttributeJoin<?,?> joinedFromElement) {
public Object visitQualifiedAttributeJoin(SqmAttributeJoin<?,?> joinedFromElement) {
joinedFromElement.visitSqmJoins( sqmJoin -> sqmJoin.accept( this ) );
return (T) joinedFromElement;
return joinedFromElement;
}
@Override
public T visitBasicValuedPath(SqmBasicValuedSimplePath path) {
return (T) path;
public Object visitBasicValuedPath(SqmBasicValuedSimplePath path) {
return path;
}
@Override
public T visitEmbeddableValuedPath(SqmEmbeddedValuedSimplePath path) {
return (T) path;
public Object visitEmbeddableValuedPath(SqmEmbeddedValuedSimplePath path) {
return path;
}
@Override
public T visitEntityValuedPath(SqmEntityValuedSimplePath path) {
return (T) path;
public Object visitEntityValuedPath(SqmEntityValuedSimplePath path) {
return path;
}
@Override
public T visitPluralValuedPath(SqmPluralValuedSimplePath path) {
return (T) path;
public Object visitPluralValuedPath(SqmPluralValuedSimplePath path) {
return path;
}
@Override
public T visitIndexedPluralAccessPath(SqmIndexedCollectionAccessPath path) {
return (T) path;
public Object visitIndexedPluralAccessPath(SqmIndexedCollectionAccessPath path) {
return path;
}
@Override
public T visitMaxElementPath(SqmMaxElementPath path) {
return (T) path;
public Object visitMaxElementPath(SqmMaxElementPath path) {
return path;
}
@Override
public T visitMinElementPath(SqmMinElementPath path) {
return (T) path;
public Object visitMinElementPath(SqmMinElementPath path) {
return path;
}
@Override
public T visitMaxIndexPath(SqmMaxIndexPath path) {
return (T) path;
public Object visitMaxIndexPath(SqmMaxIndexPath path) {
return path;
}
@Override
public T visitMinIndexPath(SqmMinIndexPath path) {
return (T) path;
public Object visitMinIndexPath(SqmMinIndexPath path) {
return path;
}
@Override
public T visitCorrelation(SqmCorrelation correlation) {
return (T) correlation;
public Object visitCorrelation(SqmCorrelation correlation) {
return correlation;
}
@Override
public T visitSelectClause(SqmSelectClause selectClause) {
public Object visitSelectClause(SqmSelectClause selectClause) {
for ( SqmSelection selection : selectClause.getSelections() ) {
// todo (6.0) : add the ability for certain SqlSelections to be sort of "implicit"...
// - they do not get rendered into the SQL, but do have a SqlReader
@ -244,116 +244,116 @@ public class BaseSemanticQueryWalker<T> implements SemanticQueryWalker<T> {
// 2) `EmptySqlSelection` : if this ends up being important at all..
visitSelection( selection );
}
return (T) selectClause;
return selectClause;
}
@Override
public T visitSelection(SqmSelection selection) {
public Object visitSelection(SqmSelection selection) {
selection.getSelectableNode().accept( this );
return (T) selection;
return selection;
}
@Override
public T visitWhereClause(SqmWhereClause whereClause) {
public Object visitWhereClause(SqmWhereClause whereClause) {
if ( whereClause == null ) {
return null;
}
whereClause.getPredicate().accept( this );
return (T) whereClause;
return whereClause;
}
@Override
public T visitGroupedPredicate(SqmGroupedPredicate predicate) {
public Object visitGroupedPredicate(SqmGroupedPredicate predicate) {
predicate.getSubPredicate().accept( this );
return (T) predicate;
return predicate;
}
@Override
public T visitAndPredicate(SqmAndPredicate predicate) {
public Object visitAndPredicate(SqmAndPredicate predicate) {
predicate.getLeftHandPredicate().accept( this );
predicate.getRightHandPredicate().accept( this );
return (T) predicate;
return predicate;
}
@Override
public T visitOrPredicate(SqmOrPredicate predicate) {
public Object visitOrPredicate(SqmOrPredicate predicate) {
predicate.getLeftHandPredicate().accept( this );
predicate.getRightHandPredicate().accept( this );
return (T) predicate;
return predicate;
}
@Override
public T visitComparisonPredicate(SqmComparisonPredicate predicate) {
public Object visitComparisonPredicate(SqmComparisonPredicate predicate) {
predicate.getLeftHandExpression().accept( this );
predicate.getRightHandExpression().accept( this );
return (T) predicate;
return predicate;
}
@Override
public T visitIsEmptyPredicate(SqmEmptinessPredicate predicate) {
public Object visitIsEmptyPredicate(SqmEmptinessPredicate predicate) {
predicate.getPluralPath().accept( this );
return (T) predicate;
return predicate;
}
@Override
public T visitIsNullPredicate(SqmNullnessPredicate predicate) {
public Object visitIsNullPredicate(SqmNullnessPredicate predicate) {
predicate.getExpression().accept( this );
return (T) predicate;
return predicate;
}
@Override
public T visitBetweenPredicate(SqmBetweenPredicate predicate) {
public Object visitBetweenPredicate(SqmBetweenPredicate predicate) {
predicate.getExpression().accept( this );
predicate.getLowerBound().accept( this );
predicate.getUpperBound().accept( this );
return (T) predicate;
return predicate;
}
@Override
public T visitLikePredicate(SqmLikePredicate predicate) {
public Object visitLikePredicate(SqmLikePredicate predicate) {
predicate.getMatchExpression().accept( this );
predicate.getPattern().accept( this );
predicate.getEscapeCharacter().accept( this );
return (T) predicate;
return predicate;
}
@Override
public T visitMemberOfPredicate(SqmMemberOfPredicate predicate) {
public Object visitMemberOfPredicate(SqmMemberOfPredicate predicate) {
predicate.getPluralPath().accept( this );
return (T) predicate;
return predicate;
}
@Override
public T visitNegatedPredicate(SqmNegatedPredicate predicate) {
public Object visitNegatedPredicate(SqmNegatedPredicate predicate) {
predicate.getWrappedPredicate().accept( this );
return (T) predicate;
return predicate;
}
@Override
public T visitInListPredicate(SqmInListPredicate<?> predicate) {
public Object visitInListPredicate(SqmInListPredicate<?> predicate) {
predicate.getTestExpression().accept( this );
for ( SqmExpression expression : predicate.getListExpressions() ) {
expression.accept( this );
}
return (T) predicate;
return predicate;
}
@Override
public T visitInSubQueryPredicate(SqmInSubQueryPredicate<?> predicate) {
public Object visitInSubQueryPredicate(SqmInSubQueryPredicate<?> predicate) {
predicate.getTestExpression().accept( this );
predicate.getSubQueryExpression().accept( this );
return (T) predicate;
return predicate;
}
@Override
public T visitBooleanExpressionPredicate(SqmBooleanExpressionPredicate predicate) {
public Object visitBooleanExpressionPredicate(SqmBooleanExpressionPredicate predicate) {
predicate.getBooleanExpression().accept( this );
return (T) predicate;
return predicate;
}
@Override
public T visitOrderByClause(SqmOrderByClause orderByClause) {
public Object visitOrderByClause(SqmOrderByClause orderByClause) {
if ( orderByClause == null ) {
return null;
}
@ -363,17 +363,17 @@ public class BaseSemanticQueryWalker<T> implements SemanticQueryWalker<T> {
visitSortSpecification( sortSpecification );
}
}
return (T) orderByClause;
return orderByClause;
}
@Override
public T visitSortSpecification(SqmSortSpecification sortSpecification) {
public Object visitSortSpecification(SqmSortSpecification sortSpecification) {
sortSpecification.getSortExpression().accept( this );
return (T) sortSpecification;
return sortSpecification;
}
@Override
public T visitOffsetExpression(SqmExpression<?> expression) {
public Object visitOffsetExpression(SqmExpression<?> expression) {
if ( expression == null ) {
return null;
}
@ -382,25 +382,25 @@ public class BaseSemanticQueryWalker<T> implements SemanticQueryWalker<T> {
}
@Override
public T visitGroupByClause(SqmGroupByClause clause) {
public Object visitGroupByClause(SqmGroupByClause clause) {
clause.visitGroupings( this::visitGrouping );
return (T) clause;
return clause;
}
@Override
public T visitGrouping(SqmGroupByClause.SqmGrouping grouping) {
public Object visitGrouping(SqmGroupByClause.SqmGrouping grouping) {
grouping.getExpression().accept( this );
return (T) grouping;
return grouping;
}
@Override
public T visitHavingClause(SqmHavingClause clause) {
public Object visitHavingClause(SqmHavingClause clause) {
clause.getPredicate().accept( this );
return (T) clause;
return clause;
}
@Override
public T visitLimitExpression(SqmExpression<?> expression) {
public Object visitLimitExpression(SqmExpression<?> expression) {
if ( expression == null ) {
return null;
}
@ -409,69 +409,69 @@ public class BaseSemanticQueryWalker<T> implements SemanticQueryWalker<T> {
}
@Override
public T visitPositionalParameterExpression(SqmPositionalParameter expression) {
return (T) expression;
public Object visitPositionalParameterExpression(SqmPositionalParameter expression) {
return expression;
}
@Override
public T visitNamedParameterExpression(SqmNamedParameter expression) {
return (T) expression;
public Object visitNamedParameterExpression(SqmNamedParameter expression) {
return expression;
}
@Override
public T visitCriteriaParameter(SqmCriteriaParameter expression) {
return (T) expression;
public Object visitCriteriaParameter(SqmCriteriaParameter expression) {
return expression;
}
@Override
public T visitEntityTypeLiteralExpression(SqmLiteralEntityType expression) {
return (T) expression;
public Object visitEntityTypeLiteralExpression(SqmLiteralEntityType expression) {
return expression;
}
@Override
public T visitParameterizedEntityTypeExpression(SqmEntityType expression) {
return (T) expression;
public Object visitParameterizedEntityTypeExpression(SqmEntityType expression) {
return expression;
}
@Override
public T visitUnaryOperationExpression(SqmUnaryOperation sqmExpression) {
public Object visitUnaryOperationExpression(SqmUnaryOperation sqmExpression) {
sqmExpression.getOperand().accept( this );
return (T) sqmExpression;
return sqmExpression;
}
@Override
public T visitFunction(SqmFunction sqmFunction) {
return (T) sqmFunction;
public Object visitFunction(SqmFunction sqmFunction) {
return sqmFunction;
}
@Override
public T visitRestrictedSubQueryExpression(SqmRestrictedSubQueryExpression<?> sqmRestrictedSubQueryExpression) {
public Object visitRestrictedSubQueryExpression(SqmRestrictedSubQueryExpression<?> sqmRestrictedSubQueryExpression) {
return sqmRestrictedSubQueryExpression.getSubQuery().accept( this );
}
@Override
public T visitExtractUnit(SqmExtractUnit extractUnit) {
return (T) extractUnit;
public Object visitExtractUnit(SqmExtractUnit extractUnit) {
return extractUnit;
}
@Override
public T visitCastTarget(SqmCastTarget castTarget) {
return (T) castTarget;
public Object visitCastTarget(SqmCastTarget castTarget) {
return castTarget;
}
@Override
public T visitTrimSpecification(SqmTrimSpecification trimSpecification) {
return (T) trimSpecification;
public Object visitTrimSpecification(SqmTrimSpecification trimSpecification) {
return trimSpecification;
}
@Override
public T visitDistinct(SqmDistinct distinct) {
return (T) distinct;
public Object visitDistinct(SqmDistinct distinct) {
return distinct;
}
@Override
public T visitStar(SqmStar sqmStar) {
return (T) sqmStar;
public Object visitStar(SqmStar sqmStar) {
return sqmStar;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -479,68 +479,68 @@ public class BaseSemanticQueryWalker<T> implements SemanticQueryWalker<T> {
@Override
public T visitTreatedPath(SqmTreatedPath sqmTreatedPath) {
public Object visitTreatedPath(SqmTreatedPath sqmTreatedPath) {
throw new NotYetImplementedFor6Exception();
}
@Override
public T visitPluralAttributeSizeFunction(SqmCollectionSize function) {
return (T) function;
public Object visitPluralAttributeSizeFunction(SqmCollectionSize function) {
return function;
}
@Override
public T visitMapEntryFunction(SqmMapEntryReference binding) {
return (T) binding;
public Object visitMapEntryFunction(SqmMapEntryReference binding) {
return binding;
}
@Override
public T visitLiteral(SqmLiteral literal) {
return (T) literal;
public Object visitLiteral(SqmLiteral literal) {
return literal;
}
@Override
public T visitTuple(SqmTuple sqmTuple) {
return (T) sqmTuple;
public Object visitTuple(SqmTuple sqmTuple) {
return sqmTuple;
}
@Override
public T visitBinaryArithmeticExpression(SqmBinaryArithmetic expression) {
return (T) expression;
public Object visitBinaryArithmeticExpression(SqmBinaryArithmetic expression) {
return expression;
}
@Override
public T visitSubQueryExpression(SqmSubQuery expression) {
return (T) expression;
public Object visitSubQueryExpression(SqmSubQuery expression) {
return expression;
}
@Override
public T visitSimpleCaseExpression(SqmCaseSimple<?,?> expression) {
return (T) expression;
public Object visitSimpleCaseExpression(SqmCaseSimple<?,?> expression) {
return expression;
}
@Override
public T visitSearchedCaseExpression(SqmCaseSearched<?> expression) {
return (T) expression;
public Object visitSearchedCaseExpression(SqmCaseSearched<?> expression) {
return expression;
}
@Override
public T visitDynamicInstantiation(SqmDynamicInstantiation<?> sqmDynamicInstantiation) {
return (T) sqmDynamicInstantiation;
public Object visitDynamicInstantiation(SqmDynamicInstantiation<?> sqmDynamicInstantiation) {
return sqmDynamicInstantiation;
}
@Override
public T visitFullyQualifiedClass(Class<?> namedClass) {
public Object visitFullyQualifiedClass(Class<?> namedClass) {
throw new UnsupportedOperationException( "Not supported" );
}
@Override
public T visitEnumLiteral(SqmEnumLiteral sqmEnumLiteral) {
public Object visitEnumLiteral(SqmEnumLiteral sqmEnumLiteral) {
throw new UnsupportedOperationException( "Not supported" );
}
@Override
public T visitFieldLiteral(SqmFieldLiteral sqmFieldLiteral) {
public Object visitFieldLiteral(SqmFieldLiteral sqmFieldLiteral) {
throw new UnsupportedOperationException( "Not supported" );
}

View File

@ -5,7 +5,7 @@
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.query.sqm.consume.spi;
package org.hibernate.query.sqm.spi;
import java.util.HashMap;
import java.util.HashSet;

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.query.sqm.consume.spi;
package org.hibernate.query.sqm.spi;
import java.util.List;
import java.util.Map;

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.query.sqm.produce.spi;
package org.hibernate.query.sqm.spi;
import org.hibernate.query.sqm.tree.expression.SqmParameter;

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.query.sqm.consume.spi;
package org.hibernate.query.sqm.spi;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.query.sqm.tree.delete.SqmDeleteStatement;
@ -78,6 +78,8 @@ import org.hibernate.query.sqm.tree.update.SqmSetClause;
import org.hibernate.query.sqm.tree.update.SqmUpdateStatement;
/**
* Support for walking a Semantic Query Model (SQM) tree
*
* @author Steve Ebersole
*/
public interface SemanticQueryWalker<T> {

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.query.sqm.produce.spi;
package org.hibernate.query.sqm.spi;
import org.hibernate.Incubating;
import org.hibernate.metamodel.model.domain.JpaMetamodel;

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.query.sqm.produce;
package org.hibernate.query.sqm.spi;
import org.hibernate.query.NavigablePath;
import org.hibernate.query.sqm.tree.domain.SqmPath;

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.query.sqm.produce.spi;
package org.hibernate.query.sqm.spi;
import org.hibernate.Incubating;
import org.hibernate.query.sqm.StrictJpaComplianceViolation;

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.query.sqm.produce.spi;
package org.hibernate.query.sqm.spi;
import org.hibernate.Incubating;
import org.hibernate.query.hql.spi.SqmPathRegistry;

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.query.sqm.produce.spi;
package org.hibernate.query.sqm.spi;
import org.hibernate.Incubating;
import org.hibernate.internal.util.collections.Stack;

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.query.sqm.produce.spi;
package org.hibernate.query.sqm.spi;
import org.hibernate.Incubating;
import org.hibernate.query.sqm.tree.select.SqmSelectQuery;

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.query.sqm.consume.spi;
package org.hibernate.query.sqm.spi;
import org.hibernate.sql.ast.spi.SqlAstCreationState;
@ -13,6 +13,5 @@ import org.hibernate.sql.ast.spi.SqlAstCreationState;
*
* @author Steve Ebersole
*/
@SuppressWarnings("WeakerAccess")
public interface SqmToSqlAstConverter<T> extends SemanticQueryWalker<T>, SqlAstCreationState {
public interface SqmToSqlAstConverter extends SemanticQueryWalker<Object>, SqlAstCreationState {
}

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.query.sqm.produce;
package org.hibernate.query.sqm.spi;
import org.hibernate.Internal;
import org.hibernate.query.QueryLogger;

View File

@ -4,15 +4,8 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.query.sqm.produce.internal;
/**
* @author Steve Ebersole
* SPI-level SQM contracts
*/
public class UniqueIdGenerator {
private long uidSequence = 0;
public String generateUniqueId() {
return "<uid:" + ++uidSequence + ">";
}
}
package org.hibernate.query.sqm.spi;

View File

@ -6,7 +6,7 @@
*/
package org.hibernate.query.sqm.tree;
import org.hibernate.query.sqm.consume.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.spi.SemanticQueryWalker;
/**
* Optional contract for SqmNode implementations that can be visited

View File

@ -16,7 +16,7 @@ import org.hibernate.query.criteria.JpaCriteriaDelete;
import org.hibernate.query.criteria.JpaPredicate;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.SqmQuerySource;
import org.hibernate.query.sqm.consume.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.tree.AbstractSqmDmlStatement;
import org.hibernate.query.sqm.tree.SqmDeleteOrUpdateStatement;
import org.hibernate.query.sqm.tree.from.SqmRoot;

View File

@ -16,8 +16,8 @@ import org.hibernate.query.criteria.JpaPredicate;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.SqmJoinable;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.consume.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.produce.SqmCreationHelper;
import org.hibernate.query.sqm.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.spi.SqmCreationHelper;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.query.sqm.tree.from.SqmAttributeJoin;
import org.hibernate.query.sqm.tree.from.SqmFrom;

View File

@ -40,7 +40,7 @@ import org.hibernate.query.SemanticException;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.UnknownPathException;
import org.hibernate.query.hql.spi.SemanticPathPart;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.query.sqm.tree.from.SqmAttributeJoin;
import org.hibernate.query.sqm.tree.from.SqmFrom;

View File

@ -27,7 +27,7 @@ import org.hibernate.query.NavigablePath;
import org.hibernate.query.sqm.IllegalPathUsageException;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.query.sqm.tree.expression.AbstractSqmExpression;
import org.hibernate.query.sqm.tree.expression.SqmExpression;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;

View File

@ -13,9 +13,9 @@ import org.hibernate.query.NavigablePath;
import org.hibernate.query.PathException;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.consume.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.spi.SemanticQueryWalker;
import org.hibernate.query.hql.spi.SemanticPathPart;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationState;
/**
* @author Steve Ebersole

View File

@ -16,13 +16,13 @@ import javax.persistence.metamodel.SingularAttribute;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.metamodel.model.domain.BagPersistentAttribute;
import org.hibernate.metamodel.model.domain.EntityDomainType;
import org.hibernate.query.PathException;
import org.hibernate.query.criteria.JpaCollectionJoin;
import org.hibernate.query.criteria.JpaExpression;
import org.hibernate.query.criteria.JpaPredicate;
import org.hibernate.query.criteria.JpaSubQuery;
import org.hibernate.query.PathException;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.produce.spi.SqmCreationProcessingState;
import org.hibernate.query.sqm.spi.SqmCreationProcessingState;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.query.sqm.tree.from.SqmAttributeJoin;
import org.hibernate.query.sqm.tree.from.SqmFrom;
@ -134,6 +134,7 @@ public class SqmBagJoin<O, E> extends AbstractSqmPluralJoin<O,Collection<E>, E>
@Override
public SqmAttributeJoin makeCopy(SqmCreationProcessingState creationProcessingState) {
//noinspection unchecked
return new SqmBagJoin(
creationProcessingState.getPathRegistry().findFromByPath( getLhs().getNavigablePath() ),
getReferencedPathSource(),

View File

@ -9,12 +9,12 @@ package org.hibernate.query.sqm.tree.domain;
import org.hibernate.metamodel.model.domain.EntityDomainType;
import org.hibernate.query.NavigablePath;
import org.hibernate.query.PathException;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.SemanticException;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.consume.spi.SemanticQueryWalker;
import org.hibernate.query.hql.spi.SemanticPathPart;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.type.descriptor.java.BasicJavaDescriptor;
/**

View File

@ -8,7 +8,7 @@ package org.hibernate.query.sqm.tree.domain;
import org.hibernate.query.criteria.JpaSubQuery;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.consume.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.tree.from.SqmFrom;
import org.hibernate.query.sqm.tree.from.SqmRoot;
import org.hibernate.query.sqm.tree.select.SqmSubQuery;

View File

@ -14,8 +14,8 @@ import org.hibernate.query.hql.spi.SemanticPathPart;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.UnknownPathException;
import org.hibernate.query.sqm.consume.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.spi.SqmCreationState;
/**
* @author Steve Ebersole

View File

@ -12,8 +12,8 @@ import org.hibernate.query.PathException;
import org.hibernate.query.hql.spi.SemanticPathPart;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.consume.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.spi.SqmCreationState;
/**
* @author Steve Ebersole

View File

@ -6,15 +6,14 @@
*/
package org.hibernate.query.sqm.tree.domain;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.metamodel.model.domain.EntityDomainType;
import org.hibernate.metamodel.model.domain.PluralPersistentAttribute;
import org.hibernate.query.NavigablePath;
import org.hibernate.query.PathException;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.consume.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.spi.SemanticQueryWalker;
import org.hibernate.query.hql.spi.SemanticPathPart;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.query.sqm.tree.expression.SqmExpression;
/**

View File

@ -17,13 +17,13 @@ import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.metamodel.model.domain.EntityDomainType;
import org.hibernate.metamodel.model.domain.ListPersistentAttribute;
import org.hibernate.query.NavigablePath;
import org.hibernate.query.PathException;
import org.hibernate.query.criteria.JpaExpression;
import org.hibernate.query.criteria.JpaListJoin;
import org.hibernate.query.criteria.JpaPredicate;
import org.hibernate.query.criteria.JpaSubQuery;
import org.hibernate.query.PathException;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.produce.spi.SqmCreationProcessingState;
import org.hibernate.query.sqm.spi.SqmCreationProcessingState;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.query.sqm.tree.from.SqmAttributeJoin;
import org.hibernate.query.sqm.tree.from.SqmFrom;
@ -32,7 +32,9 @@ import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
/**
* @author Steve Ebersole
*/
public class SqmListJoin<O,E> extends AbstractSqmPluralJoin<O,List<E>, E> implements JpaListJoin<O, E> {
public class SqmListJoin<O,E>
extends AbstractSqmPluralJoin<O,List<E>, E>
implements JpaListJoin<O, E> {
public SqmListJoin(
SqmFrom<?,O> lhs,
ListPersistentAttribute<O, E> listAttribute,
@ -141,6 +143,7 @@ public class SqmListJoin<O,E> extends AbstractSqmPluralJoin<O,List<E>, E> implem
@Override
public SqmAttributeJoin makeCopy(SqmCreationProcessingState creationProcessingState) {
//noinspection unchecked
return new SqmListJoin(
creationProcessingState.getPathRegistry().findFromByPath( getLhs().getNavigablePath() ),
getReferencedPathSource(),

View File

@ -18,8 +18,9 @@ import javax.persistence.criteria.Predicate;
import org.hibernate.query.criteria.JpaSelection;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.SqmExpressable;
import org.hibernate.query.sqm.consume.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.tree.select.SqmSelectableNode;
import org.hibernate.sql.results.spi.DomainResultProducer;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
@ -30,7 +31,8 @@ import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
* @author Gunnar Morling
* @author Steve Ebersole
*/
public class SqmMapEntryReference<K,V> implements SqmSelectableNode<Map.Entry<K,V>>, Expression<Map.Entry<K,V>> {
public class SqmMapEntryReference<K,V>
implements SqmSelectableNode<Map.Entry<K,V>>, Expression<Map.Entry<K,V>>, DomainResultProducer<Map.Entry<K,V>> {
@SuppressWarnings({"FieldCanBeLocal", "unused"})
private final SqmPath<?> mapPath;
private final NodeBuilder nodeBuilder;
@ -82,6 +84,11 @@ public class SqmMapEntryReference<K,V> implements SqmSelectableNode<Map.Entry<K,
return walker.visitMapEntryFunction( this );
}
@Override
public DomainResultProducer<Map.Entry<K, V>> getDomainResultProducer() {
return this;
}
@Override
public void visitSubSelectableNodes(Consumer<SqmSelectableNode<?>> jpaSelectionConsumer) {
}

View File

@ -16,14 +16,14 @@ import org.hibernate.metamodel.model.domain.EmbeddableDomainType;
import org.hibernate.metamodel.model.domain.EntityDomainType;
import org.hibernate.metamodel.model.domain.MapPersistentAttribute;
import org.hibernate.query.NavigablePath;
import org.hibernate.query.PathException;
import org.hibernate.query.criteria.JpaExpression;
import org.hibernate.query.criteria.JpaMapJoin;
import org.hibernate.query.criteria.JpaPredicate;
import org.hibernate.query.criteria.JpaSubQuery;
import org.hibernate.query.PathException;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.produce.spi.SqmCreationProcessingState;
import org.hibernate.query.sqm.spi.SqmCreationProcessingState;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.query.sqm.tree.from.SqmAttributeJoin;
import org.hibernate.query.sqm.tree.from.SqmFrom;
@ -32,7 +32,9 @@ import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
/**
* @author Steve Ebersole
*/
public class SqmMapJoin<O,K,V> extends AbstractSqmPluralJoin<O,Map<K,V>,V> implements JpaMapJoin<O,K,V> {
public class SqmMapJoin<O,K,V>
extends AbstractSqmPluralJoin<O,Map<K,V>,V>
implements JpaMapJoin<O,K,V> {
public SqmMapJoin(
SqmFrom<?,O> lhs,
MapPersistentAttribute<O,K,V> pluralValuedNavigable,

View File

@ -11,8 +11,8 @@ import org.hibernate.metamodel.model.domain.PluralPersistentAttribute;
import org.hibernate.query.SemanticException;
import org.hibernate.query.hql.spi.SemanticPathPart;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.consume.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.spi.SqmCreationState;
/**
* @author Steve Ebersole

View File

@ -10,9 +10,9 @@ import org.hibernate.metamodel.model.domain.ListPersistentAttribute;
import org.hibernate.metamodel.model.domain.MapPersistentAttribute;
import org.hibernate.metamodel.model.domain.PluralPersistentAttribute;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.consume.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.spi.SemanticQueryWalker;
import org.hibernate.query.hql.spi.SemanticPathPart;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationState;
/**
* @author Steve Ebersole

View File

@ -10,9 +10,9 @@ import org.hibernate.metamodel.model.domain.ManagedDomainType;
import org.hibernate.metamodel.model.domain.PluralPersistentAttribute;
import org.hibernate.query.SemanticException;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.consume.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.spi.SemanticQueryWalker;
import org.hibernate.query.hql.spi.SemanticPathPart;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationState;
/**
* @author Steve Ebersole

View File

@ -10,9 +10,9 @@ import org.hibernate.metamodel.model.domain.ListPersistentAttribute;
import org.hibernate.metamodel.model.domain.MapPersistentAttribute;
import org.hibernate.metamodel.model.domain.PluralPersistentAttribute;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.consume.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.spi.SemanticQueryWalker;
import org.hibernate.query.hql.spi.SemanticPathPart;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationState;
/**
* @author Steve Ebersole

View File

@ -6,10 +6,8 @@
*/
package org.hibernate.query.sqm.tree.domain;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Supplier;
import org.hibernate.metamodel.model.domain.EntityDomainType;
import org.hibernate.query.NavigablePath;
@ -20,9 +18,10 @@ import org.hibernate.query.hql.spi.SemanticPathPart;
import org.hibernate.query.sqm.ParsingException;
import org.hibernate.query.sqm.SqmExpressable;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.query.sqm.tree.expression.SqmExpression;
import org.hibernate.query.sqm.tree.from.SqmRoot;
import org.hibernate.sql.results.spi.DomainResultProducer;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
/**
@ -32,7 +31,7 @@ import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
*
* @author Steve Ebersole
*/
public interface SqmPath<T> extends SqmExpression<T>, SemanticPathPart, JpaPath<T> {
public interface SqmPath<T> extends SqmExpression<T>, SemanticPathPart, JpaPath<T>, DomainResultProducer<T> {
/**
* Returns the NavigablePath.
@ -47,6 +46,11 @@ public interface SqmPath<T> extends SqmExpression<T>, SemanticPathPart, JpaPath<
*/
SqmPathSource<?> getReferencedPathSource();
@Override
default DomainResultProducer<T> getDomainResultProducer() {
return this;
}
/**
* Retrieve the explicit alias, if one. May return null
*/

View File

@ -14,9 +14,9 @@ import org.hibernate.persister.collection.CollectionPropertyNames;
import org.hibernate.query.NavigablePath;
import org.hibernate.query.PathException;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.consume.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.spi.SemanticQueryWalker;
import org.hibernate.query.hql.spi.SemanticPathPart;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationState;
/**
* An SqmPath for plural attribute paths

View File

@ -34,7 +34,7 @@ import org.hibernate.metamodel.model.domain.PluralPersistentAttribute;
import org.hibernate.metamodel.model.domain.SimpleDomainType;
import org.hibernate.metamodel.model.domain.SingularPersistentAttribute;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
/**

View File

@ -16,13 +16,13 @@ import javax.persistence.metamodel.SingularAttribute;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.metamodel.model.domain.EntityDomainType;
import org.hibernate.metamodel.model.domain.SetPersistentAttribute;
import org.hibernate.query.PathException;
import org.hibernate.query.criteria.JpaExpression;
import org.hibernate.query.criteria.JpaPredicate;
import org.hibernate.query.criteria.JpaSetJoin;
import org.hibernate.query.criteria.JpaSubQuery;
import org.hibernate.query.PathException;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.produce.spi.SqmCreationProcessingState;
import org.hibernate.query.sqm.spi.SqmCreationProcessingState;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.query.sqm.tree.from.SqmAttributeJoin;
import org.hibernate.query.sqm.tree.from.SqmFrom;

View File

@ -7,16 +7,26 @@
package org.hibernate.query.sqm.tree.domain;
import java.util.Locale;
import java.util.function.Consumer;
import org.hibernate.HibernateException;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.metamodel.model.domain.EmbeddableDomainType;
import org.hibernate.metamodel.model.domain.EntityDomainType;
import org.hibernate.metamodel.model.domain.ManagedDomainType;
import org.hibernate.metamodel.model.domain.SingularPersistentAttribute;
import org.hibernate.persister.SqlExpressableType;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.query.PathException;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.produce.spi.SqmCreationProcessingState;
import org.hibernate.query.sqm.spi.SqmCreationProcessingState;
import org.hibernate.query.sqm.tree.SqmJoinType;
import org.hibernate.query.sqm.tree.from.SqmAttributeJoin;
import org.hibernate.query.sqm.tree.from.SqmFrom;
import org.hibernate.sql.ast.Clause;
import org.hibernate.sql.results.spi.DomainResultProducer;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
import org.hibernate.type.spi.TypeConfiguration;
/**
* @author Steve Ebersole
@ -75,4 +85,33 @@ public class SqmSingularJoin<O,T> extends AbstractSqmAttributeJoin<O,T> {
nodeBuilder()
);
}
@Override
public void visitJdbcTypes(Consumer<SqlExpressableType> action, TypeConfiguration typeConfiguration) {
// todo (6.0) : better as some form of PersistentAttribute -> org.hibernate.persister.walking.spi.AttributeDefinition resolution
final SingularPersistentAttribute<O, T> attribute = getReferencedPathSource();
final ManagedDomainType<O> attributeType = (ManagedDomainType<O>) attribute.getType();
if ( attributeType instanceof EntityDomainType<?> ) {
final EntityDomainType<?> entityDomainType = (EntityDomainType<?>) attributeType;
final String entityName = entityDomainType.getHibernateEntityName();
final EntityPersister entityDescriptor = typeConfiguration.getSessionFactory()
.getMetamodel()
.getEntityDescriptor( entityName );
entityDescriptor.visitValueMappings(
valueMapping -> valueMapping.getWriteable().visitJdbcTypes(
action,
Clause.IRRELEVANT,
typeConfiguration
)
);
}
else if ( attributeType instanceof EmbeddableDomainType<?> ) {
throw new NotYetImplementedFor6Exception( getClass() );
}
else {
throw new HibernateException( "Unexpected declaring " );
}
}
}

View File

@ -8,7 +8,7 @@ package org.hibernate.query.sqm.tree.domain;
import org.hibernate.metamodel.model.domain.BagPersistentAttribute;
import org.hibernate.metamodel.model.domain.EntityDomainType;
import org.hibernate.query.sqm.produce.spi.SqmCreationProcessingState;
import org.hibernate.query.sqm.spi.SqmCreationProcessingState;
import org.hibernate.query.sqm.tree.from.SqmAttributeJoin;
/**

View File

@ -8,8 +8,8 @@ package org.hibernate.query.sqm.tree.domain;
import org.hibernate.metamodel.model.domain.EntityDomainType;
import org.hibernate.metamodel.model.domain.ListPersistentAttribute;
import org.hibernate.query.sqm.produce.spi.SqmCreationProcessingState;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationProcessingState;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.query.sqm.tree.expression.SqmExpression;
import org.hibernate.query.sqm.tree.from.SqmAttributeJoin;

View File

@ -7,7 +7,7 @@
package org.hibernate.query.sqm.tree.domain;
import org.hibernate.metamodel.model.domain.EntityDomainType;
import org.hibernate.query.sqm.produce.spi.SqmCreationProcessingState;
import org.hibernate.query.sqm.spi.SqmCreationProcessingState;
import org.hibernate.query.sqm.tree.from.SqmAttributeJoin;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;

View File

@ -8,7 +8,7 @@ package org.hibernate.query.sqm.tree.domain;
import org.hibernate.metamodel.model.domain.EntityDomainType;
import org.hibernate.metamodel.model.domain.SetPersistentAttribute;
import org.hibernate.query.sqm.produce.spi.SqmCreationProcessingState;
import org.hibernate.query.sqm.spi.SqmCreationProcessingState;
import org.hibernate.query.sqm.tree.from.SqmAttributeJoin;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;

View File

@ -9,7 +9,7 @@ package org.hibernate.query.sqm.tree.domain;
import org.hibernate.metamodel.model.domain.EntityDomainType;
import org.hibernate.query.PathException;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.consume.spi.SemanticQueryWalker;
import org.hibernate.query.sqm.spi.SemanticQueryWalker;
/**
* @author Steve Ebersole

View File

@ -8,7 +8,7 @@ package org.hibernate.query.sqm.tree.domain;
import org.hibernate.metamodel.model.domain.EntityDomainType;
import org.hibernate.metamodel.model.domain.SingularPersistentAttribute;
import org.hibernate.query.sqm.produce.spi.SqmCreationProcessingState;
import org.hibernate.query.sqm.spi.SqmCreationProcessingState;
import org.hibernate.query.sqm.tree.from.SqmAttributeJoin;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;

View File

@ -14,7 +14,7 @@ import javax.persistence.criteria.Expression;
import org.hibernate.query.criteria.JpaSelection;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.SqmExpressable;
import org.hibernate.query.sqm.produce.SqmTreeCreationLogger;
import org.hibernate.query.sqm.spi.SqmTreeCreationLogger;
import org.hibernate.query.sqm.tree.jpa.AbstractJpaSelection;
import org.hibernate.query.sqm.tree.predicate.SqmPredicate;
import org.hibernate.type.StandardBasicTypes;

View File

@ -14,7 +14,7 @@ import java.time.LocalDateTime;
import java.time.LocalTime;
import org.hibernate.query.spi.QueryEngine;
import org.hibernate.query.sqm.produce.spi.SqmCreationState;
import org.hibernate.query.sqm.spi.SqmCreationState;
import org.hibernate.type.StandardBasicTypes;
import org.hibernate.type.descriptor.java.JdbcDateTypeDescriptor;
import org.hibernate.type.descriptor.java.JdbcTimeTypeDescriptor;

Some files were not shown because too many files have changed in this diff Show More