Search in sources :

Example 1 with ASTQueryTranslatorFactory

use of org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory in project hibernate-orm by hibernate.

the class CollectionPropertyDeprecationsTest method compileQuery.

private QueryTranslatorImpl compileQuery(String hql) {
    QueryTranslatorFactory ast = new ASTQueryTranslatorFactory();
    QueryTranslatorImpl newQueryTranslator = (QueryTranslatorImpl) ast.createQueryTranslator(hql, hql, Collections.EMPTY_MAP, sessionFactory(), null);
    newQueryTranslator.compile(Collections.emptyMap(), false);
    return newQueryTranslator;
}
Also used : QueryTranslatorFactory(org.hibernate.hql.spi.QueryTranslatorFactory) ASTQueryTranslatorFactory(org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory) ASTQueryTranslatorFactory(org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory) QueryTranslatorImpl(org.hibernate.hql.internal.ast.QueryTranslatorImpl)

Example 2 with ASTQueryTranslatorFactory

use of org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory in project hibernate-orm by hibernate.

the class QueryTranslatorTestCase method createNewQueryTranslator.

private QueryTranslatorImpl createNewQueryTranslator(String hql, Map replacements, boolean scalar, SessionFactoryImplementor factory) {
    QueryTranslatorFactory ast = new ASTQueryTranslatorFactory();
    QueryTranslatorImpl newQueryTranslator = (QueryTranslatorImpl) ast.createQueryTranslator(hql, hql, Collections.EMPTY_MAP, factory, null);
    newQueryTranslator.compile(replacements, scalar);
    return newQueryTranslator;
}
Also used : ClassicQueryTranslatorFactory(org.hibernate.hql.internal.classic.ClassicQueryTranslatorFactory) ASTQueryTranslatorFactory(org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory) QueryTranslatorFactory(org.hibernate.hql.spi.QueryTranslatorFactory) ASTQueryTranslatorFactory(org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory) QueryTranslatorImpl(org.hibernate.hql.internal.ast.QueryTranslatorImpl)

Example 3 with ASTQueryTranslatorFactory

use of org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory in project hibernate-orm by hibernate.

the class EJBQLTest method toSql.

private String toSql(String hql) {
    QueryTranslatorFactory ast = new ASTQueryTranslatorFactory();
    QueryTranslator queryTranslator = ast.createQueryTranslator(hql, hql, Collections.EMPTY_MAP, sessionFactory(), null);
    queryTranslator.compile(Collections.EMPTY_MAP, true);
    return queryTranslator.getSQLString();
}
Also used : QueryTranslatorFactory(org.hibernate.hql.spi.QueryTranslatorFactory) ASTQueryTranslatorFactory(org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory) QueryTranslator(org.hibernate.hql.spi.QueryTranslator) ASTQueryTranslatorFactory(org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory)

Example 4 with ASTQueryTranslatorFactory

use of org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory in project hibernate-orm by hibernate.

the class LocaleTest method testAliasWithLocale.

@Test
@TestForIssue(jiraKey = "HHH-8579")
public void testAliasWithLocale() {
    // Without the HHH-8579 fix, this will generate non-ascii query aliases.
    String hql = "from IAmAFoo";
    QueryTranslatorFactory ast = new ASTQueryTranslatorFactory();
    QueryTranslator queryTranslator = ast.createQueryTranslator(hql, hql, Collections.EMPTY_MAP, sessionFactory(), null);
    queryTranslator.compile(Collections.EMPTY_MAP, false);
    String sql = queryTranslator.getSQLString();
    assertTrue(sql.matches(asciiRegex));
}
Also used : QueryTranslatorFactory(org.hibernate.hql.spi.QueryTranslatorFactory) ASTQueryTranslatorFactory(org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory) QueryTranslator(org.hibernate.hql.spi.QueryTranslator) ASTQueryTranslatorFactory(org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory) Test(org.junit.Test) TestForIssue(org.hibernate.testing.TestForIssue)

Example 5 with ASTQueryTranslatorFactory

use of org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory in project hibernate-orm by hibernate.

the class QueryTranslatorFactoryInitiator method initiateService.

@Override
public QueryTranslatorFactory initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
    final StrategySelector strategySelector = registry.getService(StrategySelector.class);
    final QueryTranslatorFactory factory = strategySelector.resolveDefaultableStrategy(QueryTranslatorFactory.class, configurationValues.get(QUERY_TRANSLATOR), ASTQueryTranslatorFactory.INSTANCE);
    log.debugf("QueryTranslatorFactory : %s", factory);
    if (factory instanceof ASTQueryTranslatorFactory) {
        log.usingAstQueryTranslatorFactory();
    }
    return factory;
}
Also used : QueryTranslatorFactory(org.hibernate.hql.spi.QueryTranslatorFactory) ASTQueryTranslatorFactory(org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory) StrategySelector(org.hibernate.boot.registry.selector.spi.StrategySelector) ASTQueryTranslatorFactory(org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory)

Aggregations

ASTQueryTranslatorFactory (org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory)10 QueryTranslatorFactory (org.hibernate.hql.spi.QueryTranslatorFactory)10 QueryTranslator (org.hibernate.hql.spi.QueryTranslator)7 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)3 QueryTranslatorImpl (org.hibernate.hql.internal.ast.QueryTranslatorImpl)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ClassicQueryTranslatorFactory (org.hibernate.hql.internal.classic.ClassicQueryTranslatorFactory)2 TreeMap (java.util.TreeMap)1 MappingException (org.hibernate.MappingException)1 QueryException (org.hibernate.QueryException)1 StrategySelector (org.hibernate.boot.registry.selector.spi.StrategySelector)1 TestForIssue (org.hibernate.testing.TestForIssue)1 Test (org.junit.Test)1