Search in sources :

Example 36 with SqlSelection

use of org.hibernate.sql.ast.spi.SqlSelection in project hibernate-orm by hibernate.

the class BasicValuedCollectionPart method generateFetch.

@Override
public Fetch generateFetch(FetchParent fetchParent, NavigablePath fetchablePath, FetchTiming fetchTiming, boolean selected, String resultVariable, DomainResultCreationState creationState) {
    ResultsLogger.LOGGER.debugf("Generating Fetch for collection-part : `%s` -> `%s`", collectionDescriptor.getRole(), nature.getName());
    NavigablePath parentNavigablePath = fetchablePath.getParent();
    if (parentNavigablePath instanceof EntityIdentifierNavigablePath) {
        parentNavigablePath = parentNavigablePath.getParent();
    }
    final TableGroup tableGroup = creationState.getSqlAstCreationState().getFromClauseAccess().findTableGroup(parentNavigablePath);
    final SqlSelection sqlSelection = resolveSqlSelection(fetchablePath, tableGroup, true, creationState);
    return new BasicFetch<>(sqlSelection.getValuesArrayPosition(), fetchParent, fetchablePath, this, valueConverter, FetchTiming.IMMEDIATE, creationState);
}
Also used : BasicFetch(org.hibernate.sql.results.graph.basic.BasicFetch) EntityIdentifierNavigablePath(org.hibernate.query.sqm.spi.EntityIdentifierNavigablePath) NavigablePath(org.hibernate.query.spi.NavigablePath) TableGroup(org.hibernate.sql.ast.tree.from.TableGroup) PluralTableGroup(org.hibernate.sql.ast.tree.from.PluralTableGroup) EntityIdentifierNavigablePath(org.hibernate.query.sqm.spi.EntityIdentifierNavigablePath) SqlSelection(org.hibernate.sql.ast.spi.SqlSelection)

Example 37 with SqlSelection

use of org.hibernate.sql.ast.spi.SqlSelection in project hibernate-orm by hibernate.

the class AbstractDiscriminatorMapping method generateFetch.

@Override
public BasicFetch generateFetch(FetchParent fetchParent, NavigablePath fetchablePath, FetchTiming fetchTiming, boolean selected, String resultVariable, DomainResultCreationState creationState) {
    final SqlAstCreationState sqlAstCreationState = creationState.getSqlAstCreationState();
    final TableGroup tableGroup = sqlAstCreationState.getFromClauseAccess().getTableGroup(fetchParent.getNavigablePath());
    assert tableGroup != null;
    final SqlSelection sqlSelection = resolveSqlSelection(fetchablePath, getUnderlyingJdbcMappingType(), tableGroup, creationState.getSqlAstCreationState());
    return new BasicFetch<>(sqlSelection.getValuesArrayPosition(), fetchParent, fetchablePath, this, null, fetchTiming, creationState);
}
Also used : BasicFetch(org.hibernate.sql.results.graph.basic.BasicFetch) TableGroup(org.hibernate.sql.ast.tree.from.TableGroup) SqlAstCreationState(org.hibernate.sql.ast.spi.SqlAstCreationState) SqlSelection(org.hibernate.sql.ast.spi.SqlSelection)

Example 38 with SqlSelection

use of org.hibernate.sql.ast.spi.SqlSelection in project hibernate-orm by hibernate.

the class JdbcValuesResultSetImpl method readCurrentRowValues.

private void readCurrentRowValues() {
    final ResultSet resultSet = resultSetAccess.getResultSet();
    final SharedSessionContractImplementor session = executionContext.getSession();
    for (final SqlSelection sqlSelection : sqlSelections) {
        try {
            currentRowJdbcValues[sqlSelection.getValuesArrayPosition()] = sqlSelection.getJdbcValueExtractor().extract(resultSet, sqlSelection.getJdbcResultSetIndex(), session);
        } catch (Exception e) {
            throw new HibernateException("Unable to extract JDBC value for position `" + sqlSelection.getJdbcResultSetIndex() + "`", e);
        }
    }
}
Also used : HibernateException(org.hibernate.HibernateException) ResultSet(java.sql.ResultSet) SharedSessionContractImplementor(org.hibernate.engine.spi.SharedSessionContractImplementor) ExecutionException(org.hibernate.sql.exec.ExecutionException) SQLException(java.sql.SQLException) HibernateException(org.hibernate.HibernateException) SqlSelection(org.hibernate.sql.ast.spi.SqlSelection)

Aggregations

SqlSelection (org.hibernate.sql.ast.spi.SqlSelection)38 TableGroup (org.hibernate.sql.ast.tree.from.TableGroup)21 BasicResult (org.hibernate.sql.results.graph.basic.BasicResult)20 SqlExpressionResolver (org.hibernate.sql.ast.spi.SqlExpressionResolver)19 NavigablePath (org.hibernate.query.spi.NavigablePath)16 ColumnReference (org.hibernate.sql.ast.tree.expression.ColumnReference)15 SqlAstCreationState (org.hibernate.sql.ast.spi.SqlAstCreationState)13 DomainResultCreationState (org.hibernate.sql.results.graph.DomainResultCreationState)13 BasicFetch (org.hibernate.sql.results.graph.basic.BasicFetch)13 JavaType (org.hibernate.type.descriptor.java.JavaType)13 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)11 Expression (org.hibernate.sql.ast.tree.expression.Expression)10 TableReference (org.hibernate.sql.ast.tree.from.TableReference)10 DomainResult (org.hibernate.sql.results.graph.DomainResult)10 SharedSessionContractImplementor (org.hibernate.engine.spi.SharedSessionContractImplementor)9 EntityMappingType (org.hibernate.metamodel.mapping.EntityMappingType)9 JdbcMapping (org.hibernate.metamodel.mapping.JdbcMapping)9 BiConsumer (java.util.function.BiConsumer)8 FetchTiming (org.hibernate.engine.FetchTiming)8 IndexedConsumer (org.hibernate.mapping.IndexedConsumer)8