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" ); } } return sqlAssignmentString; }
/** * Interprets the {@code WHERE} clause from the user-defined update/delete query * * @param whereClause The user-defined {@code WHERE} clause * * @return The bulk-id-ready {@code WHERE} clause representation */ @SuppressWarnings("unchecked") 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 // ids that will be returned and inserted into the id table... 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 ); } } else { return ProcessedWhereClause.NO_WHERE_CLAUSE; } }
private void generate(AST sqlAst) throws QueryException, RecognitionException { if ( sql == null ) { final SqlGenerator gen = new SqlGenerator( factory ); gen.statement( sqlAst ); sql = gen.getSQL(); if ( LOG.isDebugEnabled() ) { LOG.debugf( "HQL: %s", hql ); LOG.debugf( "SQL: %s", sql ); } gen.getParseErrorHandler().throwQueryException(); if ( collectedParameterSpecifications == null ) { collectedParameterSpecifications = gen.getCollectedParameters(); } else { collectedParameterSpecifications.addAll( gen.getCollectedParameters() ); } } }
public BasicExecutor(HqlSqlWalker walker, Queryable persister) { this.persister = persister; try { SqlGenerator gen = new SqlGenerator( walker.getSessionFactoryHelper().getFactory() ); gen.statement( walker.getAST() ); sql = gen.getSQL(); gen.getParseErrorHandler().throwQueryException(); parameterSpecifications = gen.getCollectedParameters(); } catch ( RecognitionException e ) { throw QuerySyntaxException.convert( e ); } }
private void handleWithFragment(FromElement fromElement, AST hqlWithNode) throws SemanticException { try { withClause( hqlWithNode ); AST hqlSqlWithNode = returnAST; if ( LOG.isDebugEnabled() ) { LOG.debug( "handleWithFragment() : " + getASTPrinter().showAsString( hqlSqlWithNode, "-- with clause --" ) ); } WithClauseVisitor visitor = new WithClauseVisitor( fromElement, queryTranslatorImpl ); NodeTraverser traverser = new NodeTraverser( visitor ); traverser.traverseDepthFirst( hqlSqlWithNode ); SqlGenerator sql = new SqlGenerator( getSessionFactoryHelper().getFactory() ); sql.whereExpr( hqlSqlWithNode.getFirstChild() ); fromElement.setWithClauseFragment( "(" + sql.getSQL() + ")" ); } catch (SemanticException e) { throw e; } catch (InvalidWithClauseException e) { throw e; } catch (Exception e) { throw new SemanticException( e.getMessage() ); } }
throw new QueryException( e.getMessage(), e ); String selectorExpression = gen.getSQL(); joinSequence.addCondition( collectionTableAlias + '.' + indexCols[0] + " = " + selectorExpression ); List<ParameterSpecification> paramSpecs = gen.getCollectedParameters();
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" ); } } return sqlAssignmentString; }
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" ); } } return sqlAssignmentString; }
private void generate(AST sqlAst) throws QueryException, RecognitionException { if ( sql == null ) { SqlGenerator gen = new SqlGenerator(factory); gen.statement( sqlAst ); sql = gen.getSQL(); if ( LOG.isDebugEnabled() ) { LOG.debugf( "HQL: %s", hql ); LOG.debugf( "SQL: %s", sql ); } gen.getParseErrorHandler().throwQueryException(); collectedParameterSpecifications = gen.getCollectedParameters(); } }
private void generate(AST sqlAst) throws QueryException, RecognitionException { if ( sql == null ) { SqlGenerator gen = new SqlGenerator(factory); gen.statement( sqlAst ); sql = gen.getSQL(); if ( LOG.isDebugEnabled() ) { LOG.debugf( "HQL: %s", hql ); LOG.debugf( "SQL: %s", sql ); } gen.getParseErrorHandler().throwQueryException(); collectedParameterSpecifications = gen.getCollectedParameters(); } }
public BasicExecutor(HqlSqlWalker walker, Queryable persister) { super(walker, null); this.persister = persister; try { SqlGenerator gen = new SqlGenerator( getFactory() ); gen.statement( walker.getAST() ); sql = gen.getSQL(); gen.getParseErrorHandler().throwQueryException(); parameterSpecifications = gen.getCollectedParameters(); } catch ( RecognitionException e ) { throw QuerySyntaxException.convert( e ); } }
public BasicExecutor(HqlSqlWalker walker, Queryable persister) { super(walker, null); this.persister = persister; try { SqlGenerator gen = new SqlGenerator( getFactory() ); gen.statement( walker.getAST() ); sql = gen.getSQL(); gen.getParseErrorHandler().throwQueryException(); parameterSpecifications = gen.getCollectedParameters(); } catch ( RecognitionException e ) { throw QuerySyntaxException.convert( e ); } }
SqlGenerator sqlGenerator = new SqlGenerator( getFactory() ); sqlGenerator.whereClause( whereClause ); userWhereClause = sqlGenerator.getSQL().substring( 7 ); // strip the " where " idSelectParameterSpecifications = sqlGenerator.getCollectedParameters();
SqlGenerator sqlGenerator = new SqlGenerator( getFactory() ); sqlGenerator.whereClause( whereClause ); userWhereClause = sqlGenerator.getSQL().substring( 7 ); // strip the " where " idSelectParameterSpecifications = sqlGenerator.getCollectedParameters();
sql.whereExpr( hqlSqlWithNode.getFirstChild() ); fromElement.setWithClauseFragment( withClauseJoinAlias, "(" + sql.getSQL() + ")" );
sql.whereExpr( hqlSqlWithNode.getFirstChild() ); fromElement.setWithClauseFragment( withClauseJoinAlias, "(" + sql.getSQL() + ")" );
throw new QueryException( e.getMessage(), e ); String selectorExpression = gen.getSQL(); joinSequence.addCondition( collectionTableAlias + '.' + indexCols[0] + " = " + selectorExpression ); List paramSpecs = gen.getCollectedParameters();
throw new QueryException( e.getMessage(), e ); String selectorExpression = gen.getSQL(); joinSequence.addCondition( collectionTableAlias + '.' + indexCols[0] + " = " + selectorExpression ); List paramSpecs = gen.getCollectedParameters();