Package org.hibernate.hql.internal.ast

Examples of org.hibernate.hql.internal.ast.SqlGenerator


    String userWhereClause = "";
    if ( whereClause.getNumberOfChildren() != 0 ) {
      // If a where clause was specified in the update/delete query, use it to limit the
      // returned ids here...
      try {
        SqlGenerator sqlGenerator = new SqlGenerator( getFactory() );
        sqlGenerator.whereClause( whereClause );
        userWhereClause = sqlGenerator.getSQL().substring( 7 )// strip the " where "
        idSelectParameterSpecifications = sqlGenerator.getCollectedParameters();
      }
      catch ( RecognitionException e ) {
        throw new HibernateException( "Unable to generate id select for DML operation", e );
      }
      if ( whereJoinFragment.length() > 0 ) {
View Full Code Here


  protected ProcessedWhereClause processWhereClause(AST whereClause) {
    if ( whereClause.getNumberOfChildren() != 0 ) {
      // If a where clause was specified in the update/delete query, use it to limit the
      // returned ids here...
      try {
        SqlGenerator sqlGenerator = new SqlGenerator( sessionFactory );
        sqlGenerator.whereClause( whereClause );
        String userWhereClause = sqlGenerator.getSQL().substring( 7 )// strip the " where "
        List<ParameterSpecification> idSelectParameterSpecifications = sqlGenerator.getCollectedParameters();

        return new ProcessedWhereClause( userWhereClause, idSelectParameterSpecifications );
      }
      catch ( RecognitionException e ) {
        throw new HibernateException( "Unable to generate id select for DML operation", e );
View Full Code Here

  }

  public String getSqlAssignmentFragment() {
    if ( sqlAssignmentString == null ) {
      try {
        SqlGenerator sqlGenerator = new SqlGenerator( factory );
        sqlGenerator.comparisonExpr(
            eq,
            false
        )// false indicates to not generate parens around the assignment
        sqlAssignmentString = sqlGenerator.getSQL();
      }
      catch (Throwable t) {
        throw new QueryException( "cannot interpret set-clause assignment" );
      }
    }
View Full Code Here

    JoinSequence joinSequence = fromElement.getJoinSequence();
    String[] indexCols = queryableCollection.getIndexColumnNames();
    if ( indexCols.length != 1 ) {
      throw new QueryException( "composite-index appears in []: " + collectionNode.getPath() );
    }
    SqlGenerator gen = new SqlGenerator( getSessionFactoryHelper().getFactory() );
    try {
      gen.simpleExpr( selector ); //TODO: used to be exprNoParens! was this needed?
    }
    catch (RecognitionException e) {
      throw new QueryException( e.getMessage(), e );
    }
    String selectorExpression = gen.getSQL();
    joinSequence.addCondition( collectionTableAlias + '.' + indexCols[0] + " = " + selectorExpression );
    List<ParameterSpecification> paramSpecs = gen.getCollectedParameters();
    if ( paramSpecs != null ) {
      switch ( paramSpecs.size() ) {
        case 0:
          // nothing to do
          break;
View Full Code Here

  public BasicExecutor(HqlSqlWalker walker, Queryable persister) {
    this.factory = walker.getSessionFactoryHelper().getFactory();
    this.persister = persister;
    try {
      SqlGenerator gen = new SqlGenerator( factory );
      gen.statement( walker.getAST() );
      sql = gen.getSQL();
      gen.getParseErrorHandler().throwQueryException();
      parameterSpecifications = gen.getCollectedParameters();
    }
    catch ( RecognitionException e ) {
      throw QuerySyntaxException.convert( e );
    }
  }
View Full Code Here

      final DeleteStatement deleteStatement = (DeleteStatement) walker.getAST();
     
      final String idSubselectWhere;
      if ( deleteStatement.hasWhereClause() ) {
        final AST whereClause = deleteStatement.getWhereClause();
        final SqlGenerator gen = new SqlGenerator( factory );
        gen.whereClause( whereClause );
        parameterSpecifications = gen.getCollectedParameters();
        idSubselectWhere = gen.getSQL().length() > 7 ? gen.getSQL() : "";
      }
      else {
        parameterSpecifications = new ArrayList<ParameterSpecification>();
        idSubselectWhere = "";
      }
View Full Code Here

    JoinSequence joinSequence = fromElement.getJoinSequence();
    String[] indexCols = queryableCollection.getIndexColumnNames();
    if ( indexCols.length != 1 ) {
      throw new QueryException( "composite-index appears in []: " + collectionNode.getPath() );
    }
    SqlGenerator gen = new SqlGenerator( getSessionFactoryHelper().getFactory() );
    try {
      gen.simpleExpr( selector ); //TODO: used to be exprNoParens! was this needed?
    }
    catch ( RecognitionException e ) {
      throw new QueryException( e.getMessage(), e );
    }
    String selectorExpression = gen.getSQL();
    joinSequence.addCondition( collectionTableAlias + '.' + indexCols[0] + " = " + selectorExpression );
    List paramSpecs = gen.getCollectedParameters();
    if ( paramSpecs != null ) {
      switch ( paramSpecs.size() ) {
        case 0 :
          // nothing to do
          break;
View Full Code Here

  }

  public String getSqlAssignmentFragment() {
    if ( sqlAssignmentString == null ) {
      try {
        SqlGenerator sqlGenerator = new SqlGenerator( factory );
        sqlGenerator.comparisonExpr( eq, false )// false indicates to not generate parens around the assignment
        sqlAssignmentString = sqlGenerator.getSQL();
      }
      catch( Throwable t ) {
        throw new QueryException( "cannot interpret set-clause assignment" );
      }
    }
View Full Code Here

    JoinSequence joinSequence = fromElement.getJoinSequence();
    String[] indexCols = queryableCollection.getIndexColumnNames();
    if ( indexCols.length != 1 ) {
      throw new QueryException( "composite-index appears in []: " + collectionNode.getPath() );
    }
    SqlGenerator gen = new SqlGenerator( getSessionFactoryHelper().getFactory() );
    try {
      gen.simpleExpr( selector ); //TODO: used to be exprNoParens! was this needed?
    }
    catch ( RecognitionException e ) {
      throw new QueryException( e.getMessage(), e );
    }
    String selectorExpression = gen.getSQL();
    joinSequence.addCondition( collectionTableAlias + '.' + indexCols[0] + " = " + selectorExpression );
    List<ParameterSpecification> paramSpecs = gen.getCollectedParameters();
    if ( paramSpecs != null ) {
      switch ( paramSpecs.size() ) {
        case 0 :
          // nothing to do
          break;
View Full Code Here

  protected ProcessedWhereClause processWhereClause(AST whereClause) {
    if ( whereClause.getNumberOfChildren() != 0 ) {
      // If a where clause was specified in the update/delete query, use it to limit the
      // returned ids here...
      try {
        SqlGenerator sqlGenerator = new SqlGenerator( sessionFactory );
        sqlGenerator.whereClause( whereClause );
        String userWhereClause = sqlGenerator.getSQL().substring( 7 )// strip the " where "
        List<ParameterSpecification> idSelectParameterSpecifications = sqlGenerator.getCollectedParameters();

        return new ProcessedWhereClause( userWhereClause, idSelectParameterSpecifications );
      }
      catch ( RecognitionException e ) {
        throw new HibernateException( "Unable to generate id select for DML operation", e );
View Full Code Here

TOP

Related Classes of org.hibernate.hql.internal.ast.SqlGenerator

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.