Search in sources :

Example 6 with SqmQueryImplementor

use of org.hibernate.query.hql.spi.SqmQueryImplementor in project hibernate-orm by hibernate.

the class HqlEntityGraphTest method buildSqlSelectAst.

private <T> SelectStatement buildSqlSelectAst(Class<T> entityType, String hql, RootGraphImplementor<T> entityGraph, GraphSemantic mode, SessionImplementor session) {
    final LoadQueryInfluencers loadQueryInfluencers = new LoadQueryInfluencers(session.getSessionFactory());
    final QueryImplementor<T> query = session.createQuery(hql, entityType);
    final SqmQueryImplementor<String> hqlQuery = (SqmQueryImplementor<String>) query;
    hqlQuery.applyGraph(entityGraph, mode);
    final SqmSelectStatement<String> sqmStatement = (SqmSelectStatement<String>) hqlQuery.getSqmStatement();
    final StandardSqmTranslator<SelectStatement> sqmConverter = new StandardSqmTranslator<>(sqmStatement, hqlQuery.getQueryOptions(), ((QuerySqmImpl<?>) hqlQuery).getDomainParameterXref(), query.getParameterBindings(), loadQueryInfluencers, session.getSessionFactory(), true);
    final SqmTranslation<SelectStatement> sqmInterpretation = sqmConverter.translate();
    return sqmInterpretation.getSqlAst();
}
Also used : LoadQueryInfluencers(org.hibernate.engine.spi.LoadQueryInfluencers) SqmSelectStatement(org.hibernate.query.sqm.tree.select.SqmSelectStatement) SqmSelectStatement(org.hibernate.query.sqm.tree.select.SqmSelectStatement) SelectStatement(org.hibernate.sql.ast.tree.select.SelectStatement) SqmQueryImplementor(org.hibernate.query.hql.spi.SqmQueryImplementor) StandardSqmTranslator(org.hibernate.query.sqm.sql.internal.StandardSqmTranslator)

Aggregations

SqmQueryImplementor (org.hibernate.query.hql.spi.SqmQueryImplementor)6 StandardSqmTranslator (org.hibernate.query.sqm.sql.internal.StandardSqmTranslator)4 SqmSelectStatement (org.hibernate.query.sqm.tree.select.SqmSelectStatement)4 SelectStatement (org.hibernate.sql.ast.tree.select.SelectStatement)4 LoadQueryInfluencers (org.hibernate.engine.spi.LoadQueryInfluencers)2 NativeQueryImplementor (org.hibernate.query.sql.spi.NativeQueryImplementor)2 SqlSelection (org.hibernate.sql.ast.spi.SqlSelection)2 FromClause (org.hibernate.sql.ast.tree.from.FromClause)2 TableGroup (org.hibernate.sql.ast.tree.from.TableGroup)2 SelectClause (org.hibernate.sql.ast.tree.select.SelectClause)2 JdbcSelect (org.hibernate.sql.exec.spi.JdbcSelect)2 Test (org.junit.jupiter.api.Test)2 PersistenceException (jakarta.persistence.PersistenceException)1 CriteriaBuilder (jakarta.persistence.criteria.CriteriaBuilder)1 JdbcMappingContainer (org.hibernate.metamodel.mapping.JdbcMappingContainer)1 OrdinalEnumValueConverter (org.hibernate.metamodel.model.convert.internal.OrdinalEnumValueConverter)1 Gender (org.hibernate.orm.test.mapping.SmokeTests.Gender)1 UnknownNamedQueryException (org.hibernate.query.UnknownNamedQueryException)1 NamedObjectRepository (org.hibernate.query.named.NamedObjectRepository)1 NamedQueryMemento (org.hibernate.query.named.NamedQueryMemento)1