use of org.hibernate.query.sqm.tree.expression.SqmCollation in project hibernate-orm by hibernate.
the class SemanticQueryBuilder method visitCollateFunction.
@Override
public Object visitCollateFunction(HqlParser.CollateFunctionContext ctx) {
if (creationOptions.useStrictJpaCompliance()) {
throw new StrictJpaComplianceViolation(StrictJpaComplianceViolation.Type.COLLATIONS);
}
final SqmExpression<?> expressionToCollate = (SqmExpression<?>) ctx.getChild(2).accept(this);
final SqmCollation castTargetExpression = (SqmCollation) ctx.getChild(4).accept(this);
return getFunctionDescriptor("collate").generateSqmExpression(asList(expressionToCollate, castTargetExpression), // why not string?
null, creationContext.getQueryEngine(), creationContext.getJpaMetamodel().getTypeConfiguration());
}
use of org.hibernate.query.sqm.tree.expression.SqmCollation in project hibernate-orm by hibernate.
the class ArgumentTypesValidator method validate.
/**
* 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.
*/
@Override
public void validate(List<? extends SqmTypedNode<?>> arguments, String functionName, QueryEngine queryEngine) {
delegate.validate(arguments, functionName, queryEngine);
int count = 0;
for (SqmTypedNode<?> argument : arguments) {
JdbcTypeIndicators indicators = queryEngine.getTypeConfiguration().getCurrentBaseSqlTypeIndicators();
SqmExpressible<?> nodeType = argument.getNodeType();
FunctionParameterType type = count < types.length ? types[count++] : types[types.length - 1];
if (nodeType != null) {
JavaType<?> javaType = nodeType.getExpressibleJavaType();
if (javaType != null) {
try {
JdbcType jdbcType = javaType.getRecommendedJdbcType(indicators);
checkType(count, functionName, type, jdbcType.getJdbcTypeCode(), javaType.getJavaTypeClass());
} catch (JdbcTypeRecommendationException e) {
// it's a converter or something like that, and we will check it later
}
}
switch(type) {
case TEMPORAL_UNIT:
if (!(argument instanceof SqmExtractUnit) && !(argument instanceof SqmDurationUnit)) {
throwError(type, Object.class, functionName, count);
}
break;
// something crazy by the parser
case TRIM_SPEC:
if (!(argument instanceof SqmTrimSpecification)) {
throwError(type, Object.class, functionName, count);
}
break;
case COLLATION:
if (!(argument instanceof SqmCollation)) {
throwError(type, Object.class, functionName, count);
}
break;
}
} else {
// TODO: appropriate error?
}
}
}
Aggregations