use of org.hibernate.hql.spi.QueryTranslator 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();
}
use of org.hibernate.hql.spi.QueryTranslator in project hibernate-orm by hibernate.
the class EntityJoinTest method testNoImpliedJoinGeneratedForEqualityComparison.
@Test
@TestForIssue(jiraKey = "HHH-11538")
public void testNoImpliedJoinGeneratedForEqualityComparison() {
doInHibernate(this::sessionFactory, session -> {
final HQLQueryPlan plan = sessionFactory().getQueryPlanCache().getHQLQueryPlan("select r.id, cust.name " + "from FinancialRecord r " + " join Customer cust on r.customer = cust" + " order by r.id", false, Collections.EMPTY_MAP);
assertEquals(1, plan.getTranslators().length);
final QueryTranslator translator = plan.getTranslators()[0];
final String generatedSql = translator.getSQLString();
int tableReferenceIndex = generatedSql.indexOf(" customer ");
assertNotEquals("Generated SQL doesn't contain a table reference for customer", -1, tableReferenceIndex);
int nextTableReferenceIndex = generatedSql.indexOf(" customer ", tableReferenceIndex + 1);
assertEquals("Generated SQL wrongly joined customer twice", -1, nextTableReferenceIndex);
});
}
use of org.hibernate.hql.spi.QueryTranslator 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));
}
use of org.hibernate.hql.spi.QueryTranslator in project jbosstools-hibernate by jbosstools.
the class FacadeFactoryTest method testCreateQueryTranslator.
@Test
public void testCreateQueryTranslator() {
QueryTranslator queryTranslator = (QueryTranslator) Proxy.newProxyInstance(facadeFactory.getClassLoader(), new Class[] { QueryTranslator.class }, new TestInvocationHandler());
IQueryTranslator facade = facadeFactory.createQueryTranslator(queryTranslator);
Assert.assertSame(queryTranslator, ((IFacade) facade).getTarget());
}
use of org.hibernate.hql.spi.QueryTranslator in project jbosstools-hibernate by jbosstools.
the class FacadeFactoryTest method testCreateQueryTranslator.
@Test
public void testCreateQueryTranslator() {
QueryTranslator queryTranslator = (QueryTranslator) Proxy.newProxyInstance(facadeFactory.getClassLoader(), new Class[] { QueryTranslator.class }, new TestInvocationHandler());
IQueryTranslator facade = facadeFactory.createQueryTranslator(queryTranslator);
Assert.assertSame(queryTranslator, ((IFacade) facade).getTarget());
}
Aggregations