/** * PUBLIC: * Used to set the limit for the maximum number of rows that any ResultSet can contain to the given number. * This method should only be set once per query. To change the max rows use another query. * This method limits the number of candidate results returned to TopLink that can be used to build objects */ public void setMaxRows(int maxRows) { if ( isPrepared() && this.maxRows != maxRows){ if ( this.getCall()!=null && this.getCall().shouldIgnoreFirstRowMaxResultsSettings() && this.maxRows>0 ){ }else{ setIsPrepared(false); } } this.maxRows = maxRows; shouldCloneCall=true; }
/** * PUBLIC: * Used to set the first result in any result set that is returned for this query. * On supported database platforms this will cause the query to issue specific SQL * that avoids selecting the firstResult number of rows. * Otherwise by it will use the JDBC absolute to skip the firstResult number of rows. */ public void setFirstResult(int firstResult) { if (isPrepared() && this.firstResult != firstResult) { if (getCall()!=null && getCall().shouldIgnoreFirstRowMaxResultsSettings()) { // Don't need to reprepare as firstResult is already built into the sql if ignoreFirstRowMaxResultsSettings is set, // firstResult is just a query parameter. } else { setIsPrepared(false); } } this.firstResult = firstResult; this.shouldCloneCall = true; }
/** * INTERNAL: * Prepare the receiver for execution in a session. */ public void prepareForExecution() throws QueryException { super.prepareForExecution(); DatabaseCall databaseCall = this.getCall(); if ( databaseCall !=null && databaseCall.shouldIgnoreFirstRowMaxResultsSettings() ){ AbstractRecord parameters = this.getTranslationRow(); if (parameters.isEmpty()){ parameters = new DatabaseRecord(); } parameters.add(DatabaseCall.FIRSTRESULT_FIELD, this.getFirstResult()); parameters.add(DatabaseCall.MAXROW_FIELD, session.getPlatform().computeMaxRowsForSQL(this.getFirstResult(), this.getMaxRows())); this.setTranslationRow(parameters); } }
if (!call.shouldIgnoreFirstRowMaxResultsSettings()){ call.setMaxRows(readQuery.getMaxRows()); if (readQuery.getFirstResult() != 0) { if (!call.shouldIgnoreFirstRowMaxResultsSettings()){ call.setMaxRows(readQuery.getMaxRows()); if (readQuery.getFirstResult() != 0) {
readStatementsCount++; if (!dbCall.shouldIgnoreFirstRowMaxResultsSettings() && dbCall.getFirstResult() != 0) { resultSet.absolute(dbCall.getFirstResult());