org.hibernate.hql.ast.ASTQueryTranslatorFactory Java Examples
The following examples show how to use
org.hibernate.hql.ast.ASTQueryTranslatorFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QueryUtil.java From ctsms with GNU Lesser General Public License v2.1 | 5 votes |
private static String hqlToSql(String hqlQueryText, SessionFactory sessionFactory) { if (hqlQueryText != null && hqlQueryText.trim().length() > 0 && sessionFactory != null) { final QueryTranslatorFactory translatorFactory = new ASTQueryTranslatorFactory(); final SessionFactoryImplementor factory = (SessionFactoryImplementor) sessionFactory; final QueryTranslator translator = translatorFactory .createQueryTranslator(hqlQueryText, hqlQueryText, Collections.EMPTY_MAP, factory); translator.compile(Collections.EMPTY_MAP, false); return translator.getSQLString(); } return null; }
Example #2
Source File: HibernateUtil.java From document-management-system with GNU General Public License v2.0 | 5 votes |
/** * HQL to SQL translator */ public static String toSql(String hql) { if (hql != null && hql.trim().length() > 0) { final QueryTranslatorFactory qtf = new ASTQueryTranslatorFactory(); final SessionFactoryImplementor sfi = (SessionFactoryImplementor) sessionFactory; final QueryTranslator translator = qtf.createQueryTranslator(hql, hql, Collections.EMPTY_MAP, sfi); translator.compile(Collections.EMPTY_MAP, false); return translator.getSQLString(); } return null; }
Example #3
Source File: EJBQLTest.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
private void assertEjbqlEqualsHql(String ejbql, String hql) { QueryTranslatorFactory ast = new ASTQueryTranslatorFactory(); QueryTranslator queryTranslator = ast.createQueryTranslator( hql, hql, Collections.EMPTY_MAP, sfi() ); queryTranslator.compile( Collections.EMPTY_MAP, true ); String hqlSql = queryTranslator.getSQLString(); queryTranslator = ast.createQueryTranslator( ejbql, ejbql, Collections.EMPTY_MAP, sfi() ); queryTranslator.compile( Collections.EMPTY_MAP, true ); String ejbqlSql = queryTranslator.getSQLString(); assertEquals( hqlSql, ejbqlSql ); }
Example #4
Source File: EJBQLTest.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
private QueryTranslatorImpl compile(String input) { QueryTranslatorFactory ast = new ASTQueryTranslatorFactory(); QueryTranslator queryTranslator = ast.createQueryTranslator( input, input, Collections.EMPTY_MAP, sfi() ); queryTranslator.compile( Collections.EMPTY_MAP, true ); return ( QueryTranslatorImpl ) queryTranslator; }
Example #5
Source File: HQLTest.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
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 ); newQueryTranslator.compile( replacements, scalar ); }
Example #6
Source File: QueryTranslatorTestCase.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
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 ); newQueryTranslator.compile( replacements, scalar ); return newQueryTranslator; }
Example #7
Source File: EJBQLTest.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
private String toSql(String hql) { QueryTranslatorFactory ast = new ASTQueryTranslatorFactory(); QueryTranslator queryTranslator = ast.createQueryTranslator( hql, hql, Collections.EMPTY_MAP, sfi() ); queryTranslator.compile( Collections.EMPTY_MAP, true ); return queryTranslator.getSQLString(); }
Example #8
Source File: ASTParserLoadingTest.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
public void configure(Configuration cfg) { super.configure( cfg ); cfg.setProperty( Environment.USE_QUERY_CACHE, "true" ); cfg.setProperty( Environment.GENERATE_STATISTICS, "true" ); cfg.setProperty( Environment.QUERY_TRANSLATOR, ASTQueryTranslatorFactory.class.getName() ); }