Package org.hibernate.hql

Examples of org.hibernate.hql.QueryTranslator


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


  }

  protected void runClassicTranslator(String hql) throws Exception {
    SessionFactoryImplementor factory = getSessionFactoryImplementor();
    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;
    }
    String oldsql = oldQueryTranslator.getSQLString();
    System.out.println( "HQL    : " + hql );
    System.out.println( "OLD SQL: " + oldsql );
  }
View Full Code Here

    if ( replacements == null ) {
      replacements = new HashMap();
    }

    // steve -> note that the empty maps here represent the currently enabled filters...
    QueryTranslator oldQueryTranslator = null;
    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 ) {
      oldException = e;
    }

    QueryTranslator newQueryTranslator = null;
    Exception newException = null;
    try {
      System.out.println("Compiling with AST QueryTranslator...");
      newQueryTranslator = createNewQueryTranslator( hql, replacements, scalar );
    }
View Full Code Here

      assertTrue( "New query space does not contain " + o + "!", querySpaces.contains( o ) );
    }
  }

  protected Exception compileBadHql(String hql, boolean scalar) {
    QueryTranslator newQueryTranslator;
    Map replacements = null;
    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

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

    assertEquals( hqlSql, ejbqlSql );
  }

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

    return ast;
  }

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

    translator = createNewQueryTranslator( "select sum(h.bigDecimalValue) from Human h" );
    assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
    assertEquals( "incorrect return type", Hibernate.BIG_DECIMAL, translator.getReturnTypes()[0] );

    // special case to test classicquery special case handling of count(*)
    QueryTranslator oldQueryTranslator = null;
    String hql = "select count(*) from Human h";
    QueryTranslatorFactory classic = new ClassicQueryTranslatorFactory();
    oldQueryTranslator = classic.createQueryTranslator( hql, hql, Collections.EMPTY_MAP, getSessionFactoryImplementor() );
    oldQueryTranslator.compile( Collections.EMPTY_MAP, true);
    assertEquals( "incorrect return type count", 1, oldQueryTranslator.getReturnTypes().length );
    assertEquals( "incorrect return type", Hibernate.LONG, oldQueryTranslator.getReturnTypes()[0] );

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

TOP

Related Classes of org.hibernate.hql.QueryTranslator

Copyright © 2018 www.massapicom. 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.