use of org.hibernate.sql.ast.tree.cte.SearchClauseSpecification in project hibernate-orm by hibernate.
the class BaseSqmToSqlAstConverter method visitSearchBySpecifications.
protected List<SearchClauseSpecification> visitSearchBySpecifications(CteTable cteTable, List<SqmSearchClauseSpecification> searchBySpecifications) {
if (searchBySpecifications == null || searchBySpecifications.isEmpty()) {
return null;
}
final int size = searchBySpecifications.size();
final List<SearchClauseSpecification> searchClauseSpecifications = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
final SqmSearchClauseSpecification specification = searchBySpecifications.get(i);
forEachCteColumn(cteTable, specification.getCteColumn(), cteColumn -> searchClauseSpecifications.add(new SearchClauseSpecification(cteColumn, specification.getSortOrder(), specification.getNullPrecedence())));
}
return searchClauseSpecifications;
}
use of org.hibernate.sql.ast.tree.cte.SearchClauseSpecification in project hibernate-orm by hibernate.
the class AbstractSqlAstTranslator method renderSearchClause.
protected void renderSearchClause(CteStatement cte) {
String separator;
if (cte.getSearchClauseKind() != null) {
appendSql(" search ");
if (cte.getSearchClauseKind() == CteSearchClauseKind.DEPTH_FIRST) {
appendSql(" depth ");
} else {
appendSql(" breadth ");
}
appendSql(" first by ");
separator = "";
for (SearchClauseSpecification searchBySpecification : cte.getSearchBySpecifications()) {
appendSql(separator);
appendSql(searchBySpecification.getCteColumn().getColumnExpression());
if (searchBySpecification.getSortOrder() != null) {
if (searchBySpecification.getSortOrder() == SortOrder.ASCENDING) {
appendSql(" asc");
} else {
appendSql(" desc");
}
if (searchBySpecification.getNullPrecedence() != null) {
if (searchBySpecification.getNullPrecedence() == NullPrecedence.FIRST) {
appendSql(" nulls first");
} else {
appendSql(" nulls last");
}
}
}
separator = COMA_SEPARATOR;
}
}
}
Aggregations