Package org.hibernate.query.sqm.internal
Class SqmUtil
java.lang.Object
org.hibernate.query.sqm.internal.SqmUtil
Helper utilities for dealing with SQM
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckQueryReturnType(SqmQueryPart<?> queryPart, Class<?> expectedResultType) Similar tovalidateQueryReturnType(SqmQueryPart, Class)but does not check ifisResultTypeAlwaysAllowed(Class).static JdbcParameterBindingscreateJdbcParameterBindings(QueryParameterBindings domainParamBindings, DomainParameterXref domainParameterXref, Map<QueryParameterImplementor<?>, Map<SqmParameter<?>, List<JdbcParametersList>>> jdbcParamXref, SqmParameterMappingModelResolutionAccess mappingModelResolutionAccess, SharedSessionContractImplementor session) static @Nullable StringdetermineAffectedTableName(TableGroup tableGroup, ValuedModelPart mapping) static BindabledetermineParameterType(QueryParameterBinding<?> binding, QueryParameterImplementor<?> parameter, List<? extends SqmParameter<?>> sqmParameters, SqmParameterMappingModelResolutionAccess mappingModelResolutionAccess, SessionFactoryImplementor sessionFactory) expectingNonSelect(SqmStatement<?> sqm, String hqlString) static <T,A> SqmAttributeJoin <T, A> findCompatibleFetchJoin(SqmFrom<?, T> sqmFrom, SqmPathSource<A> pathSource, SqmJoinType requestedJoinType) static Map<QueryParameterImplementor<?>, Map<SqmParameter<?>, List<JdbcParametersList>>> generateJdbcParamsXref(DomainParameterXref domainParameterXref, JdbcParameterBySqmParameterAccess jdbcParameterBySqmParameterAccess) static List<NavigablePath> getGroupByNavigablePaths(SqmQuerySpec<?> querySpec) static List<NavigablePath> getOrderByNavigablePaths(SqmQuerySpec<?> querySpec) static Set<ParameterExpression<?>> getParameters(SqmStatement<?> statement) static ModelPartContainergetTargetMappingIfNeeded(SqmPath<?> sqmPath, ModelPartContainer modelPartContainer, SqmToSqlAstConverter sqlAstCreationState) Utility that returns the entity association target's mapping type if the specifiedsqmPathshould be dereferenced using the target table, i.e.static List<NavigablePath> getWhereClauseNavigablePaths(SqmQuerySpec<?> querySpec) static booleanisFkOptimizationAllowed(SqmPath<?> sqmPath) Deprecated, for removal: This API element is subject to removal in a future version.static booleanisFkOptimizationAllowed(SqmPath<?> sqmPath, EntityAssociationMapping associationMapping) Utility that returnsfalsewhen the providedsqmPathis a join that cannot be dereferenced through the foreign key on the associated table, i.e.static booleanisHqlTuple(SqmSelection<?> selection) static booleanisMutation(SqmStatement<?> sqm) static <T> booleanisRestrictedMutation(SqmStatement<T> sqmStatement) static booleanisResultTypeAlwaysAllowed(Class<?> expectedResultClass) static booleanisSelect(SqmStatement<?> sqm) static booleanisSelectionAssignableToResultType(SqmSelection<?> selection, Class<?> expectedResultType) static Class<?> resolveExpressibleJavaTypeClass(SqmExpression<?> expression) resolveParameters(SqmStatement<?> statement) static <X> SqmPredicaterestriction(SqmSelectStatement<X> sqmStatement, Class<X> resultType, Restriction<? super X> restriction) static SqmSortSpecificationsortSpecification(SqmSelectStatement<?> sqm, Order<?> order) static voidvalidateCriteriaQuery(SqmQueryPart<?> queryPart) static voidvalidateQueryReturnType(SqmQueryPart<?> queryPart, @Nullable Class<?> expectedResultType) Used to validate that the specified query return type is valid (i.e.static voidverifyIsNonSelectStatement(SqmStatement<?> sqm, String hqlString) static voidverifyIsRestrictedMutation(SqmStatement<?> sqm, String hqlString) static voidverifyIsSelectStatement(SqmStatement<?> sqm, String hqlString) protected static voidverifyResultType(Class<?> resultClass, SqmSelectableNode<?> selectableNode)
-
Method Details
-
isSelect
-
isMutation
-
isRestrictedMutation
-
verifyIsSelectStatement
-
verifyIsNonSelectStatement
-
expectingNonSelect
public static IllegalQueryOperationException expectingNonSelect(SqmStatement<?> sqm, String hqlString) -
verifyIsRestrictedMutation
-
determineAffectedTableName
public static @Nullable String determineAffectedTableName(TableGroup tableGroup, ValuedModelPart mapping) -
getTargetMappingIfNeeded
public static ModelPartContainer getTargetMappingIfNeeded(SqmPath<?> sqmPath, ModelPartContainer modelPartContainer, SqmToSqlAstConverter sqlAstCreationState) Utility that returns the entity association target's mapping type if the specifiedsqmPathshould be dereferenced using the target table, i.e. when the path's lhs is an explicit join that is used in the group by clause, or defaults to the providedmodelPartContainerotherwise. -
isFkOptimizationAllowed
@Deprecated(forRemoval=true, since="6.6.1") public static boolean isFkOptimizationAllowed(SqmPath<?> sqmPath) Deprecated, for removal: This API element is subject to removal in a future version.Utility that returnsfalsewhen the providedsqmPathis a join that cannot be dereferenced through the foreign key on the associated table, i.e. a join that's neither SqmJoinType.INNER nor SqmJoinType.LEFT or one that has an explicit on clause predicate. -
isFkOptimizationAllowed
public static boolean isFkOptimizationAllowed(SqmPath<?> sqmPath, EntityAssociationMapping associationMapping) Utility that returnsfalsewhen the providedsqmPathis a join that cannot be dereferenced through the foreign key on the associated table, i.e. a join that's neither SqmJoinType.INNER nor SqmJoinType.LEFT or one that has an explicit on clause predicate. -
findCompatibleFetchJoin
public static <T,A> SqmAttributeJoin<T,A> findCompatibleFetchJoin(SqmFrom<?, T> sqmFrom, SqmPathSource<A> pathSource, SqmJoinType requestedJoinType) -
generateJdbcParamsXref
public static Map<QueryParameterImplementor<?>,Map<SqmParameter<?>, generateJdbcParamsXrefList<JdbcParametersList>>> (DomainParameterXref domainParameterXref, JdbcParameterBySqmParameterAccess jdbcParameterBySqmParameterAccess) -
determineParameterType
public static Bindable determineParameterType(QueryParameterBinding<?> binding, QueryParameterImplementor<?> parameter, List<? extends SqmParameter<?>> sqmParameters, SqmParameterMappingModelResolutionAccess mappingModelResolutionAccess, SessionFactoryImplementor sessionFactory) -
resolveParameters
-
sortSpecification
-
isSelectionAssignableToResultType
public static boolean isSelectionAssignableToResultType(SqmSelection<?> selection, Class<?> expectedResultType) -
isHqlTuple
-
resolveExpressibleJavaTypeClass
-
restriction
public static <X> SqmPredicate restriction(SqmSelectStatement<X> sqmStatement, Class<X> resultType, Restriction<? super X> restriction) -
validateCriteriaQuery
-
validateQueryReturnType
public static void validateQueryReturnType(SqmQueryPart<?> queryPart, @Nullable Class<?> expectedResultType) Used to validate that the specified query return type is valid (i.e. the user did not passInteger.classwhen the selection is an entity) -
checkQueryReturnType
Similar tovalidateQueryReturnType(SqmQueryPart, Class)but does not check ifisResultTypeAlwaysAllowed(Class). -
isResultTypeAlwaysAllowed
Any query result can be represented as aTuple,List, orMap, simply by repackaging the result tuple. Also, any query result is assignable toObject, or can be returned as an instance ofObject[].- See Also:
-
verifyResultType
-
getParameters
-
isFkOptimizationAllowed(SqmPath, EntityAssociationMapping)instead