use of org.hibernate.sql.results.graph.basic.BasicResult in project hibernate-orm by hibernate.
the class DynamicResultBuilderBasicConverted method buildResult.
@Override
public BasicResult<?> buildResult(JdbcValuesMetadata jdbcResultsMetadata, int resultPosition, BiFunction<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver, DomainResultCreationState domainResultCreationState) {
final TypeConfiguration typeConfiguration = domainResultCreationState.getSqlAstCreationState().getCreationContext().getSessionFactory().getTypeConfiguration();
final SqlExpressionResolver sqlExpressionResolver = domainResultCreationState.getSqlAstCreationState().getSqlExpressionResolver();
final SqlSelection sqlSelection = sqlExpressionResolver.resolveSqlSelection(sqlExpressionResolver.resolveSqlExpression(columnAlias, state -> {
final int currentJdbcPosition = resultPosition + 1;
final int jdbcPosition;
if (columnAlias != null) {
jdbcPosition = jdbcResultsMetadata.resolveColumnPosition(columnAlias);
} else {
jdbcPosition = currentJdbcPosition;
}
final BasicType<?> basicType = jdbcResultsMetadata.resolveType(jdbcPosition, basicValueConverter.getRelationalJavaType(), domainResultCreationState.getSqlAstCreationState().getCreationContext().getSessionFactory());
final int valuesArrayPosition = ResultsHelper.jdbcPositionToValuesArrayPosition(jdbcPosition);
return new ResultSetMappingSqlSelection(valuesArrayPosition, (BasicValuedMapping) basicType);
}), basicValueConverter.getDomainJavaType(), null, typeConfiguration);
return new BasicResult<>(sqlSelection.getValuesArrayPosition(), columnAlias, basicValueConverter.getDomainJavaType(), basicValueConverter);
}
use of org.hibernate.sql.results.graph.basic.BasicResult in project hibernate-orm by hibernate.
the class JdbcLiteral method createDomainResult.
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// DomainResultProducer
@Override
public DomainResult<T> createDomainResult(String resultVariable, DomainResultCreationState creationState) {
final SqlAstCreationState sqlAstCreationState = creationState.getSqlAstCreationState();
final SqlExpressionResolver sqlExpressionResolver = sqlAstCreationState.getSqlExpressionResolver();
final SqlSelection sqlSelection = sqlExpressionResolver.resolveSqlSelection(this, jdbcMapping.getJavaTypeDescriptor(), null, sqlAstCreationState.getCreationContext().getMappingMetamodel().getTypeConfiguration());
// noinspection unchecked
return new BasicResult(sqlSelection.getValuesArrayPosition(), resultVariable, jdbcMapping.getJavaTypeDescriptor());
}
use of org.hibernate.sql.results.graph.basic.BasicResult in project hibernate-orm by hibernate.
the class QueryLiteral method createDomainResult.
@Override
public DomainResult<T> createDomainResult(String resultVariable, DomainResultCreationState creationState) {
final SqlExpressionResolver sqlExpressionResolver = creationState.getSqlAstCreationState().getSqlExpressionResolver();
final SqlSelection sqlSelection = sqlExpressionResolver.resolveSqlSelection(this, type.getMappedType().getMappedJavaType(), null, creationState.getSqlAstCreationState().getCreationContext().getSessionFactory().getTypeConfiguration());
return new BasicResult(sqlSelection.getValuesArrayPosition(), resultVariable, type.getMappedType().getMappedJavaType());
}
use of org.hibernate.sql.results.graph.basic.BasicResult in project hibernate-orm by hibernate.
the class SimpleForeignKeyDescriptor method createDomainResult.
private <T> DomainResult<T> createDomainResult(NavigablePath navigablePath, TableGroup tableGroup, SelectableMapping selectableMapping, DomainResultCreationState creationState) {
final SqlAstCreationState sqlAstCreationState = creationState.getSqlAstCreationState();
final SqlExpressionResolver sqlExpressionResolver = sqlAstCreationState.getSqlExpressionResolver();
final TableReference tableReference = tableGroup.resolveTableReference(navigablePath.append(getTargetPart().getFetchableName()), selectableMapping.getContainingTableExpression());
final String identificationVariable = tableReference.getIdentificationVariable();
final SqlSelection sqlSelection = sqlExpressionResolver.resolveSqlSelection(sqlExpressionResolver.resolveSqlExpression(SqlExpressionResolver.createColumnReferenceKey(tableReference, selectableMapping.getSelectionExpression()), s -> new ColumnReference(identificationVariable, selectableMapping, creationState.getSqlAstCreationState().getCreationContext().getSessionFactory())), selectableMapping.getJdbcMapping().getJavaTypeDescriptor(), sqlAstCreationState.getCreationContext().getSessionFactory().getTypeConfiguration());
// noinspection unchecked
return new BasicResult<T>(sqlSelection.getValuesArrayPosition(), null, selectableMapping.getJdbcMapping().getJavaTypeDescriptor());
}
use of org.hibernate.sql.results.graph.basic.BasicResult in project hibernate-orm by hibernate.
the class CompleteResultBuilderBasicValuedStandard 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 BasicValuedMapping basicType;
if (explicitType != null) {
basicType = explicitType;
} else {
basicType = jdbcResultsMetadata.resolveType(jdbcPosition, explicitJavaType, sessionFactory);
}
final int valuesArrayPosition = ResultsHelper.jdbcPositionToValuesArrayPosition(jdbcPosition);
return new ResultSetMappingSqlSelection(valuesArrayPosition, basicType);
}), explicitJavaType, null, sessionFactory.getTypeConfiguration());
return new BasicResult<>(sqlSelection.getValuesArrayPosition(), columnName, sqlSelection.getExpressionType().getJdbcMappings().get(0).getMappedJavaType());
}
Aggregations