Search in sources :

Example 1 with QueryTranslatorFactory

use of org.hibernate.hql.spi.QueryTranslatorFactory 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 QueryTranslatorFactory

use of org.hibernate.hql.spi.QueryTranslatorFactory 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 QueryTranslatorFactory

use of org.hibernate.hql.spi.QueryTranslatorFactory 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 QueryTranslatorFactory

use of org.hibernate.hql.spi.QueryTranslatorFactory 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 QueryTranslatorFactory

use of org.hibernate.hql.spi.QueryTranslatorFactory 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

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