Package org.hibernate.hql

Examples of org.hibernate.hql.QueryTranslator.compile()


      }catch (NoSuchMethodException ex) {
        e.printStackTrace();
      }
    }
   
    trans.compile(new HashMap(), false);
    sqlQuery = trans.getSQLString();
   
    logger.debug("rewrite: generated SQL query: " + sqlQuery);   
   
    return sqlQuery;
View Full Code Here


  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 );
  }

  public void testComponentNoAlias() throws Exception {
    // The classic translator doesn't do this right, so don't bother asserting.
    compileWithAstQueryTranslator( "from Human where name.first = 'Gavin'", false);
View Full Code Here

    Map replacements = new HashMap();
    QueryTranslator oldQueryTranslator = null;
    try {
      QueryTranslatorFactory classic = new ClassicQueryTranslatorFactory();
      oldQueryTranslator = classic.createQueryTranslator( hql, hql, Collections.EMPTY_MAP, factory );
      oldQueryTranslator.compile( replacements, false );
    }
    catch ( Exception e ) {
      e.printStackTrace();
      throw e;
    }
View Full Code Here

    Exception oldException = null;
    try {
      System.out.println("Compiling with classic QueryTranslator...");
      QueryTranslatorFactory classic = new ClassicQueryTranslatorFactory();
      oldQueryTranslator = classic.createQueryTranslator( hql, hql, Collections.EMPTY_MAP, factory );
      oldQueryTranslator.compile( replacements, scalar );
    }
    catch ( QueryException e ) {
      oldException = e;
    }
    catch ( MappingException e ) {
View Full Code Here

    Exception newException = null;
    SessionFactoryImplementor factory = getSessionFactoryImplementor();
    try {
      QueryTranslatorFactory ast = new ASTQueryTranslatorFactory();
      newQueryTranslator = ast.createQueryTranslator( hql, hql, Collections.EMPTY_MAP, factory );
      newQueryTranslator.compile( replacements, scalar );
    }
    catch ( QueryException e ) {
      newException = e;
    }
    catch ( MappingException e ) {
View Full Code Here

  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();
View Full Code Here

    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 );
  }
View Full Code Here

  }

  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;
  }

  private AST parse(String input, boolean logging) throws RecognitionException, TokenStreamException {
View Full Code Here

  }

  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();
  }
}
View Full Code Here

  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 );
  }

  public void testComponentNoAlias() throws Exception {
    // The classic translator doesn't do this right, so don't bother asserting.
    compileWithAstQueryTranslator( "from Human where name.first = 'Gavin'", false);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.