Package org.hibernate.hql.ast

Examples of org.hibernate.hql.ast.ASTQueryTranslatorFactory


    SessionFactoryImplementor factory = getSessionFactoryImplementor();
    return createNewQueryTranslator( hql, replacements, scalar, factory );
  }

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


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

    compileWithAstQueryTranslator("from Animal where zoo is null", false);
  }

  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

   
   
    Query hibQuery = session.createQuery(query);
    SessionFactory sessFact = session.getSessionFactory();
    SessionFactoryImplementor imple = (SessionFactoryImplementor) sessFact;
    ASTQueryTranslatorFactory factory = new ASTQueryTranslatorFactory();
    QueryTranslator trans = null;
    // Hibernate 3.0
    Class[] parsTypes = null;
   
    parsTypes = new Class[3];
   
    parsTypes[0] = String.class;
    parsTypes[1] = Map.class;
    parsTypes[2] = SessionFactoryImplementor.class;
   
    Method createQueryTranslatorMethod = null;
    try{
     
      createQueryTranslatorMethod = factory.getClass().getMethod("createQueryTranslator", parsTypes);
      try{
        trans = (QueryTranslator)createQueryTranslatorMethod.invoke(factory, new Object[]{hibQuery.getQueryString(), Collections.EMPTY_MAP, imple});
      }catch (Throwable e) {
        e.printStackTrace();
      }
    }catch (NoSuchMethodException e) {
     
      parsTypes = new Class[4];
     
      parsTypes[0] = String.class;
      parsTypes[1] = String.class;
      parsTypes[2] = Map.class;
      parsTypes[3] = SessionFactoryImplementor.class;
     
      try{
        createQueryTranslatorMethod = factory.getClass().getMethod("createQueryTranslator", parsTypes);
     
        if (createQueryTranslatorMethod != null){
          try{
            trans = (QueryTranslator)createQueryTranslatorMethod.invoke(factory, new Object[]{String.valueOf(System.currentTimeMillis()), hibQuery.getQueryString(),Collections.EMPTY_MAP, imple});
          }catch (Throwable t) {
View Full Code Here

    compileWithAstQueryTranslator("from Animal where zoo is null", false);
  }

  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

    SessionFactoryImplementor factory = getSessionFactoryImplementor();
    return createNewQueryTranslator( hql, replacements, scalar, factory );
  }

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

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

TOP

Related Classes of org.hibernate.hql.ast.ASTQueryTranslatorFactory

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.