/** * Returns the locations of all occurrences of the named parameter. */ public int[] getNamedParameterLocations(String name) throws QueryException { Object o = namedParameters.get( name ); if ( o == null ) { throw new QueryException( QueryTranslator.ERROR_NAMED_PARAMETER_DOES_NOT_APPEAR + name, queryTranslatorImpl.getQueryString() ); } if ( o instanceof Integer ) { return new int[] {(Integer) o}; } else { return ArrayHelper.toIntArray( (ArrayList) o ); } }
"Cannot mix positional and named parameters: " + queryTranslatorImpl.getQueryString() ); Locale.ROOT, ERROR_LEGACY_ORDINAL_PARAMS_NO_LONGER_SUPPORTED, queryTranslatorImpl.getQueryString()
/** * Create a new tree transformer. * * @param qti Back pointer to the query translator implementation that is using this tree transform. * @param sfi The session factory implementor where the Hibernate mappings can be found. * @param parser A reference to the phase-1 parser * @param tokenReplacements Registers the token replacement map with the walker. This map will * be used to substitute function names and constants. * @param collectionRole The collection role name of the collection used as the basis for the * filter, NULL if this is not a collection filter compilation. */ public HqlSqlWalker( QueryTranslatorImpl qti, SessionFactoryImplementor sfi, HqlParser parser, Map tokenReplacements, String collectionRole) { setASTFactory( new SqlASTFactory( this ) ); // Initialize the error handling delegate. this.parseErrorHandler = new ErrorTracker( qti.getQueryString() ); this.queryTranslatorImpl = qti; this.sessionFactoryHelper = new SessionFactoryHelper( sfi ); this.literalProcessor = new LiteralProcessor( this ); this.tokenReplacements = tokenReplacements; this.collectionFilterRole = collectionRole; this.hqlParser = parser; }
@Override protected AST generateNamedParameter(AST delimiterNode, AST nameNode) throws SemanticException { if ( getSessionFactoryHelper().isStrictJPAQLComplianceEnabled() && positionalParameters != null ) { throw new SemanticException( "Cannot mix positional and named parameters: " + queryTranslatorImpl.getQueryString() ); } final String name = nameNode.getText(); trackNamedParameterPositions( name ); // create the node initially with the param name so that it shows // appropriately in the "original text" attribute final ParameterNode parameter = (ParameterNode) astFactory.create( NAMED_PARAM, name ); parameter.setText( "?" ); final NamedParameterSpecification paramSpec = new NamedParameterSpecification( delimiterNode.getLine(), delimiterNode.getColumn(), name ); parameter.setHqlParameterSpecification( paramSpec ); parameterSpecs.add( paramSpec ); return parameter; }
@Override public String getQueryString() { return delegate.getQueryString(); }
/** * Returns the locations of all occurrences of the named parameter. */ public int[] getNamedParameterLocations(String name) throws QueryException { Object o = namedParameters.get( name ); if ( o == null ) { QueryException qe = new QueryException( QueryTranslator.ERROR_NAMED_PARAMETER_DOES_NOT_APPEAR + name ); qe.setQueryString( queryTranslatorImpl.getQueryString() ); throw qe; } if ( o instanceof Integer ) { return new int[]{( ( Integer ) o ).intValue()}; } else { return ArrayHelper.toIntArray( (ArrayList) o ); } }
/** * Returns the locations of all occurrences of the named parameter. */ public int[] getNamedParameterLocations(String name) throws QueryException { Object o = namedParameters.get( name ); if ( o == null ) { QueryException qe = new QueryException( QueryTranslator.ERROR_NAMED_PARAMETER_DOES_NOT_APPEAR + name ); qe.setQueryString( queryTranslatorImpl.getQueryString() ); throw qe; } if ( o instanceof Integer ) { return new int[]{( ( Integer ) o ).intValue()}; } else { return ArrayHelper.toIntArray( (ArrayList) o ); } }