use of org.hibernate.sql.results.graph.basic.BasicResult in project hibernate-orm by hibernate.
the class DynamicResultBuilderAttribute method buildResult.
@Override
public DomainResult<?> buildResult(JdbcValuesMetadata jdbcResultsMetadata, int resultPosition, BiFunction<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver, DomainResultCreationState domainResultCreationState) {
// todo (6.0) : TableGroups + `attributeMapping#buldResult`
final SqlExpressionResolver sqlExpressionResolver = domainResultCreationState.getSqlAstCreationState().getSqlExpressionResolver();
final SqlSelection sqlSelection = sqlExpressionResolver.resolveSqlSelection(sqlExpressionResolver.resolveSqlExpression(columnAlias, state -> {
final int resultSetPosition = jdbcResultsMetadata.resolveColumnPosition(columnAlias);
final int valuesArrayPosition = resultSetPosition - 1;
return new ResultSetMappingSqlSelection(valuesArrayPosition, attributeMapping);
}), attributeMapping.getJavaType(), null, domainResultCreationState.getSqlAstCreationState().getCreationContext().getSessionFactory().getTypeConfiguration());
return new BasicResult<>(sqlSelection.getValuesArrayPosition(), columnAlias, attributeMapping.getJavaType(), attributeMapping.getValueConverter());
}
use of org.hibernate.sql.results.graph.basic.BasicResult in project hibernate-orm by hibernate.
the class DynamicResultBuilderBasicStandard method buildResult.
@Override
public BasicResult<?> buildResult(JdbcValuesMetadata jdbcResultsMetadata, int resultPosition, BiFunction<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver, DomainResultCreationState domainResultCreationState) {
final SessionFactoryImplementor sessionFactory = domainResultCreationState.getSqlAstCreationState().getCreationContext().getSessionFactory();
final SqlExpressionResolver sqlExpressionResolver = domainResultCreationState.getSqlAstCreationState().getSqlExpressionResolver();
final Expression expression = sqlExpressionResolver.resolveSqlExpression(columnName, state -> {
final int jdbcPosition;
if (columnPosition > 0) {
jdbcPosition = columnPosition;
} else {
jdbcPosition = jdbcResultsMetadata.resolveColumnPosition(columnName);
}
final int valuesArrayPosition = ResultsHelper.jdbcPositionToValuesArrayPosition(jdbcPosition);
final BasicType<?> basicType;
if (explicitType != null) {
basicType = explicitType;
} else {
basicType = jdbcResultsMetadata.resolveType(jdbcPosition, explicitJavaType, sessionFactory);
}
return new ResultSetMappingSqlSelection(valuesArrayPosition, (BasicValuedMapping) basicType);
});
final JavaType<?> javaType;
if (explicitJavaType != null) {
javaType = explicitJavaType;
} else {
javaType = expression.getExpressionType().getJdbcMappings().get(0).getMappedJavaType();
}
final SqlSelection sqlSelection = sqlExpressionResolver.resolveSqlSelection(expression, javaType, null, sessionFactory.getTypeConfiguration());
// StandardRowReader expects there to be a JavaType as part of the ResultAssembler.
assert javaType != null;
return new BasicResult<>(sqlSelection.getValuesArrayPosition(), resultAlias, javaType);
}
use of org.hibernate.sql.results.graph.basic.BasicResult in project hibernate-orm by hibernate.
the class ImplicitModelPartResultBuilderBasic method buildResult.
@Override
public BasicResult<?> buildResult(JdbcValuesMetadata jdbcResultsMetadata, int resultPosition, BiFunction<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver, DomainResultCreationState domainResultCreationState) {
final DomainResultCreationStateImpl creationStateImpl = ResultsHelper.impl(domainResultCreationState);
final TableGroup tableGroup = creationStateImpl.getFromClauseAccess().getTableGroup(navigablePath.getParent());
return (BasicResult<?>) modelPart.createDomainResult(navigablePath, tableGroup, null, domainResultCreationState);
}
use of org.hibernate.sql.results.graph.basic.BasicResult in project hibernate-orm by hibernate.
the class EntityRowIdMappingImpl method createDomainResult.
@Override
public <T> DomainResult<T> createDomainResult(NavigablePath navigablePath, TableGroup tableGroup, String resultVariable, DomainResultCreationState creationState) {
final SqlAstCreationState sqlAstCreationState = creationState.getSqlAstCreationState();
final SqlExpressionResolver sqlExpressionResolver = sqlAstCreationState.getSqlExpressionResolver();
final TableReference columnTableReference = tableGroup.resolveTableReference(navigablePath, tableExpression);
final SqlSelection sqlSelection = sqlExpressionResolver.resolveSqlSelection(sqlExpressionResolver.resolveSqlExpression(SqlExpressionResolver.createColumnReferenceKey(columnTableReference, rowIdName), sqlAstProcessingState -> new ColumnReference(columnTableReference, rowIdName, false, // having to write a Dialect
null, null, rowIdType, sqlAstCreationState.getCreationContext().getSessionFactory())), rowIdType.getJavaTypeDescriptor(), null, sqlAstCreationState.getCreationContext().getSessionFactory().getTypeConfiguration());
return new BasicResult(sqlSelection.getValuesArrayPosition(), resultVariable, rowIdType.getJavaTypeDescriptor(), navigablePath);
}
use of org.hibernate.sql.results.graph.basic.BasicResult in project hibernate-orm by hibernate.
the class CompleteResultBuilderBasicValuedConverted method buildResult.
@Override
public BasicResult<?> buildResult(JdbcValuesMetadata jdbcResultsMetadata, int resultPosition, BiFunction<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver, DomainResultCreationState domainResultCreationState) {
final DomainResultCreationStateImpl creationStateImpl = impl(domainResultCreationState);
final SessionFactoryImplementor sessionFactory = creationStateImpl.getSessionFactory();
final String columnName;
if (explicitColumnName != null) {
columnName = explicitColumnName;
} else {
columnName = jdbcResultsMetadata.resolveColumnName(resultPosition + 1);
}
// final int jdbcPosition;
// if ( explicitColumnName != null ) {
// jdbcPosition = jdbcResultsMetadata.resolveColumnPosition( explicitColumnName );
// }
// else {
// jdbcPosition = resultPosition + 1;
// }
//
// final BasicValuedMapping basicType;
// if ( explicitType != null ) {
// basicType = explicitType;
// }
// else {
// basicType = jdbcResultsMetadata.resolveType( jdbcPosition, explicitJavaType );
// }
//
// final SqlSelection sqlSelection = creationStateImpl.resolveSqlSelection(
// creationStateImpl.resolveSqlExpression(
// columnName,
// processingState -> {
// final int valuesArrayPosition = ResultsHelper.jdbcPositionToValuesArrayPosition( jdbcPosition );
// return new SqlSelectionImpl( valuesArrayPosition, basicType );
// }
// ),
// basicType.getExpressibleJavaType(),
// sessionFactory.getTypeConfiguration()
// );
final SqlSelection sqlSelection = creationStateImpl.resolveSqlSelection(creationStateImpl.resolveSqlExpression(columnName, processingState -> {
final int jdbcPosition;
if (explicitColumnName != null) {
jdbcPosition = jdbcResultsMetadata.resolveColumnPosition(explicitColumnName);
} else {
jdbcPosition = resultPosition + 1;
}
final int valuesArrayPosition = ResultsHelper.jdbcPositionToValuesArrayPosition(jdbcPosition);
return new ResultSetMappingSqlSelection(valuesArrayPosition, underlyingMapping);
}), valueConverter.getDomainJavaType(), null, sessionFactory.getTypeConfiguration());
return new BasicResult<>(sqlSelection.getValuesArrayPosition(), columnName, valueConverter.getDomainJavaType(), valueConverter);
}
Aggregations