use of org.hibernate.query.sqm.tree.cte.SqmCteTable in project hibernate-orm by hibernate.
the class BaseSqmToSqlAstConverter method createCteTable.
public static CteTable createCteTable(SqmCteTable sqmCteTable, List<SqmCteTableColumn> sqmCteColumns, SessionFactoryImplementor factory) {
final List<CteColumn> sqlCteColumns = new ArrayList<>(sqmCteColumns.size());
for (int i = 0; i < sqmCteColumns.size(); i++) {
final SqmCteTableColumn sqmCteTableColumn = sqmCteColumns.get(i);
ValueMapping valueMapping = sqmCteTableColumn.getType();
if (valueMapping instanceof Association) {
valueMapping = ((Association) valueMapping).getForeignKeyDescriptor();
}
if (valueMapping instanceof EmbeddableValuedModelPart) {
valueMapping.forEachJdbcType((index, jdbcMapping) -> sqlCteColumns.add(new CteColumn(sqmCteTableColumn.getColumnName() + "_" + index, jdbcMapping)));
} else {
sqlCteColumns.add(new CteColumn(sqmCteTableColumn.getColumnName(), ((BasicValuedMapping) valueMapping).getJdbcMapping()));
}
}
return new CteTable(sqmCteTable.getCteName(), sqlCteColumns, factory);
}
Aggregations