use of org.hibernate.metamodel.mapping.DiscriminatedAssociationModelPart in project hibernate-orm by hibernate.
the class DiscriminatedAssociationPathInterpretation method from.
public static <T> DiscriminatedAssociationPathInterpretation<T> from(SqmAnyValuedSimplePath<T> sqmPath, SqmToSqlAstConverter converter) {
final TableGroup tableGroup = converter.getFromClauseAccess().findTableGroup(sqmPath.getLhs().getNavigablePath());
final DiscriminatedAssociationModelPart mapping = (DiscriminatedAssociationModelPart) tableGroup.getModelPart().findSubPart(sqmPath.getReferencedPathSource().getPathName(), null);
final List<Expression> tupleExpressions = new ArrayList<>();
mapping.forEachSelectable((selectionIndex, selectableMapping) -> {
final TableReference tableReference = tableGroup.resolveTableReference(sqmPath.getNavigablePath(), selectableMapping.getContainingTableExpression());
final Expression expression = converter.getSqlExpressionResolver().resolveSqlExpression(SqlExpressionResolver.createColumnReferenceKey(tableReference, selectableMapping.getSelectionExpression()), processingState -> new ColumnReference(tableReference, selectableMapping, converter.getCreationContext().getSessionFactory()));
tupleExpressions.add(expression);
});
return new DiscriminatedAssociationPathInterpretation<T>(sqmPath.getNavigablePath(), mapping, tableGroup, new SqlTuple(tupleExpressions, mapping));
}
Aggregations