use of org.hibernate.query.sqm.sql.FakeSqmToSqlAstConverter in project hibernate-orm by hibernate.
the class OrderingExpression method applyCollation.
static Expression applyCollation(Expression expression, String collation, SqlAstCreationState creationState) {
final Expression sortExpression;
if (collation == null) {
sortExpression = expression;
} else {
final QueryEngine queryEngine = creationState.getCreationContext().getSessionFactory().getQueryEngine();
final SqmToSqlAstConverter converter;
if (creationState instanceof SqmToSqlAstConverter) {
converter = (SqmToSqlAstConverter) creationState;
} else {
converter = new FakeSqmToSqlAstConverter(creationState);
}
sortExpression = queryEngine.getSqmFunctionRegistry().findFunctionDescriptor("collate").generateSqmExpression(new SqmSelfRenderingExpression<>(walker -> expression, null, null), null, queryEngine, queryEngine.getTypeConfiguration()).convertToSqlAst(converter);
}
return sortExpression;
}
Aggregations