Class ArgumentTypesValidator
- java.lang.Object
-
- org.hibernate.query.sqm.produce.function.ArgumentTypesValidator
-
- All Implemented Interfaces:
ArgumentsValidator
public class ArgumentTypesValidator extends Object implements ArgumentsValidator
Typechecks the arguments of HQL functions based on the assigned JDBC types. The main purpose for doing this is that we want to be able to check named queries at startup or build time, and we want to be able to check all queries in the IDE.
-
-
Constructor Summary
Constructors Constructor Description ArgumentTypesValidator(ArgumentsValidator delegate, FunctionParameterType... types)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getSignature()
Pretty-print the signature of the argument list.void
validate(List<? extends SqmTypedNode<?>> arguments, String functionName, QueryEngine queryEngine)
We do an initial validation phase with just the SQM tree, even though we don't have all typing information available here (in particular, we don't have the final JDBC type codes for things with converters) because this is the phase that is run at startup for named queries, and can be done in an IDE.void
validateSqlTypes(List<? extends SqlAstNode> arguments, String functionName)
This is the final validation phase with the fully-typed SQL nodes.
-
-
-
Constructor Detail
-
ArgumentTypesValidator
public ArgumentTypesValidator(ArgumentsValidator delegate, FunctionParameterType... types)
-
-
Method Detail
-
validate
public void validate(List<? extends SqmTypedNode<?>> arguments, String functionName, QueryEngine queryEngine)
We do an initial validation phase with just the SQM tree, even though we don't have all typing information available here (in particular, we don't have the final JDBC type codes for things with converters) because this is the phase that is run at startup for named queries, and can be done in an IDE.- Specified by:
validate
in interfaceArgumentsValidator
-
validateSqlTypes
public void validateSqlTypes(List<? extends SqlAstNode> arguments, String functionName)
This is the final validation phase with the fully-typed SQL nodes. Note that these checks are much less useful, occurring "too late", right before we execute the query and get an error from the database. However, they help in the sense of (a) resulting in more consistent/understandable error messages, and (b) protecting the user from writing queries that depend on generally-unportable implicit type conversions happening at the database level. (Implicit type conversions between numeric types are portable, and are not prohibited here.)- Specified by:
validateSqlTypes
in interfaceArgumentsValidator
-
getSignature
public String getSignature()
Description copied from interface:ArgumentsValidator
Pretty-print the signature of the argument list.- Specified by:
getSignature
in interfaceArgumentsValidator
-
-