Search in sources :

Example 11 with QueryTranslator

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

the class EJBQLTest method assertEjbqlEqualsHql.

private void assertEjbqlEqualsHql(String ejbql, String hql) {
    QueryTranslatorFactory ast = new ASTQueryTranslatorFactory();
    QueryTranslator queryTranslator = ast.createQueryTranslator(hql, hql, Collections.EMPTY_MAP, sessionFactory(), null);
    queryTranslator.compile(Collections.EMPTY_MAP, true);
    String hqlSql = queryTranslator.getSQLString();
    queryTranslator = ast.createQueryTranslator(ejbql, ejbql, Collections.EMPTY_MAP, sessionFactory(), null);
    queryTranslator.compile(Collections.EMPTY_MAP, true);
    String ejbqlSql = queryTranslator.getSQLString();
    assertEquals(hqlSql, ejbqlSql);
}
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 12 with QueryTranslator

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

the class EJBQLTest method compile.

private QueryTranslatorImpl compile(String input) {
    QueryTranslatorFactory ast = new ASTQueryTranslatorFactory();
    QueryTranslator queryTranslator = ast.createQueryTranslator(input, input, Collections.EMPTY_MAP, sessionFactory(), null);
    queryTranslator.compile(Collections.EMPTY_MAP, true);
    return (QueryTranslatorImpl) queryTranslator;
}
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) QueryTranslatorImpl(org.hibernate.hql.internal.ast.QueryTranslatorImpl)

Example 13 with QueryTranslator

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

the class HQLTest method compileWithAstQueryTranslator.

private void compileWithAstQueryTranslator(String hql, boolean scalar) {
    Map replacements = new HashMap();
    QueryTranslatorFactory ast = new ASTQueryTranslatorFactory();
    SessionFactoryImplementor factory = getSessionFactoryImplementor();
    QueryTranslator newQueryTranslator = ast.createQueryTranslator(hql, hql, Collections.EMPTY_MAP, factory, null);
    newQueryTranslator.compile(replacements, scalar);
}
Also used : ASTQueryTranslatorFactory(org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory) QueryTranslatorFactory(org.hibernate.hql.spi.QueryTranslatorFactory) HashMap(java.util.HashMap) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) QueryTranslator(org.hibernate.hql.spi.QueryTranslator) Map(java.util.Map) HashMap(java.util.HashMap) ASTQueryTranslatorFactory(org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory)

Example 14 with QueryTranslator

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());
}
Also used : PersistentClass(org.hibernate.mapping.PersistentClass) RootClass(org.hibernate.mapping.RootClass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) POJOClass(org.hibernate.tool.hbm2x.pojo.POJOClass) IPOJOClass(org.jboss.tools.hibernate.runtime.spi.IPOJOClass) IQueryTranslator(org.jboss.tools.hibernate.runtime.spi.IQueryTranslator) QueryTranslator(org.hibernate.hql.spi.QueryTranslator) IQueryTranslator(org.jboss.tools.hibernate.runtime.spi.IQueryTranslator) Test(org.junit.Test)

Example 15 with QueryTranslator

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());
}
Also used : PersistentClass(org.hibernate.mapping.PersistentClass) IPOJOClass(org.jboss.tools.hibernate.runtime.spi.IPOJOClass) RootClass(org.hibernate.mapping.RootClass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) POJOClass(org.hibernate.tool.hbm2x.pojo.POJOClass) IQueryTranslator(org.jboss.tools.hibernate.runtime.spi.IQueryTranslator) QueryTranslator(org.hibernate.hql.spi.QueryTranslator) IQueryTranslator(org.jboss.tools.hibernate.runtime.spi.IQueryTranslator) Test(org.junit.Test)

Aggregations

QueryTranslator (org.hibernate.hql.spi.QueryTranslator)21 Test (org.junit.Test)11 QueryTranslatorFactory (org.hibernate.hql.spi.QueryTranslatorFactory)9 ASTQueryTranslatorFactory (org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory)8 PersistentClass (org.hibernate.mapping.PersistentClass)6 RootClass (org.hibernate.mapping.RootClass)6 POJOClass (org.hibernate.tool.hbm2x.pojo.POJOClass)6 IPOJOClass (org.jboss.tools.hibernate.runtime.spi.IPOJOClass)6 IPersistentClass (org.jboss.tools.hibernate.runtime.spi.IPersistentClass)6 IQueryTranslator (org.jboss.tools.hibernate.runtime.spi.IQueryTranslator)6 HQLQueryPlan (org.hibernate.engine.query.spi.HQLQueryPlan)4 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)4 HashMap (java.util.HashMap)3 ClassicQueryTranslatorFactory (org.hibernate.hql.internal.classic.ClassicQueryTranslatorFactory)3 Map (java.util.Map)2 MappingException (org.hibernate.MappingException)2 QueryException (org.hibernate.QueryException)2 QueryTranslatorImpl (org.hibernate.hql.internal.ast.QueryTranslatorImpl)2 TestForIssue (org.hibernate.testing.TestForIssue)2 ArrayList (java.util.ArrayList)1