/** * INTERNAL: * Return true if the query uses default properties. * This is used to determine if this query is cacheable. * i.e. does not use any properties that may conflict with another query * with the same EJBQL or selection criteria. */ public boolean isDefaultPropertiesQuery() { return super.isDefaultPropertiesQuery() && (getMaxRows() == 0) && (getFirstResult() == 0) && (getFetchSize() == 0); }
int first = Math.max(0, query.getFirstResult());
/** * 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); } }
/** * INTERNAL: * Prepare the receiver for execution in a session. */ public void prepareForExecution() throws QueryException { super.prepareForExecution(); DatabaseCall databaseCall = this.getCall(); if ( databaseCall !=null && (databaseCall.shouldIgnoreFirstRowSetting() || databaseCall.shouldIgnoreMaxResultsSetting())){ AbstractRecord parameters = this.getTranslationRow(); if (parameters.isEmpty()){ parameters = new DatabaseRecord(); } //Some DB don't support FirstRow in SELECT statements in spite of supporting MaxResults(Symfoware). //We should check FirstRow and MaxResults separately. if(databaseCall.shouldIgnoreFirstRowSetting()){ parameters.add(DatabaseCall.FIRSTRESULT_FIELD, this.getFirstResult()); } if(databaseCall.shouldIgnoreMaxResultsSetting()){ parameters.add(DatabaseCall.MAXROW_FIELD, session.getPlatform().computeMaxRowsForSQL(this.getFirstResult(), this.getMaxRows())); } this.setTranslationRow(parameters); } }
this.firstResultIndex = ((ReadQuery)this.databaseQuery).getFirstResult();
/** * INTERNAL: * Prepare the receiver for execution in a session. */ public void prepareForExecution() throws QueryException { super.prepareForExecution(); DatabaseCall databaseCall = this.getCall(); if ( databaseCall !=null && (databaseCall.shouldIgnoreFirstRowSetting() || databaseCall.shouldIgnoreMaxResultsSetting())){ AbstractRecord parameters = this.getTranslationRow(); if (parameters.isEmpty()){ parameters = new DatabaseRecord(); } //Some DB don't support FirstRow in SELECT statements in spite of supporting MaxResults(Symfoware). //We should check FirstRow and MaxResults separately. if (databaseCall.shouldIgnoreFirstRowSetting()) { parameters.add(DatabaseCall.FIRSTRESULT_FIELD, this.getFirstResult()); } if (databaseCall.shouldIgnoreMaxResultsSetting()) { // Bug #493771 parameters.add(DatabaseCall.MAXROW_FIELD, ((DatabasePlatform) session.getPlatform(databaseCall.getQuery().getReferenceClass())).computeMaxRowsForSQL(this.getFirstResult(), this.getMaxRows())); } this.setTranslationRow(parameters); } }
if (readQuery.getFirstResult() != 0) { call.setFirstResult(readQuery.getFirstResult()); call.setIsResultSetScrollable(true); call.setResultSetType(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE);
if (readQuery.getFirstResult() != 0) { call.setFirstResult(readQuery.getFirstResult()); call.setIsResultSetScrollable(true); call.setResultSetType(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE);
@Override public void printSQLSelectStatement(DatabaseCall call, ExpressionSQLPrinter printer, SQLSelectStatement statement) { int max = 0; int firstRow = 0; if (statement.getQuery() != null) { max = statement.getQuery().getMaxRows(); firstRow = statement.getQuery().getFirstResult(); } if (max <= 0 || !(this.shouldUseRownumFiltering())) { super.printSQLSelectStatement(call, printer, statement); return; } statement.setUseUniqueFieldAliases(true); call.setFields(statement.printSQL(printer)); printer.printString(LIMIT); printer.printParameter(DatabaseCall.FIRSTRESULT_FIELD); printer.printString(", "); printer.printParameter(DatabaseCall.MAXROW_FIELD); call.setIgnoreFirstRowMaxResultsSettings(true); }
if (query != null) { max = query.getMaxRows(); firstRow = query.getFirstResult();
if (query != null) { max = query.getMaxRows(); firstRow = query.getFirstResult();
/** * Print the pagination SQL using FB syntax " ROWS <max> TO <first>". */ @Override public void printSQLSelectStatement(DatabaseCall call, ExpressionSQLPrinter printer, SQLSelectStatement statement) { int max = 0; int firstRow = 0; if (statement.getQuery() != null) { max = statement.getQuery().getMaxRows(); firstRow = statement.getQuery().getFirstResult(); } // Both must be set, otherwise if one is set next, the old cached SQL would be used. if (!shouldUseRownumFiltering() || (max <= 0) || (firstRow <= 0)) { super.printSQLSelectStatement(call, printer, statement); return; } statement.setUseUniqueFieldAliases(true); call.setFields(statement.printSQL(printer)); printer.printString(" ROWS ("); printer.printParameter(DatabaseCall.FIRSTRESULT_FIELD); printer.printString(" + 1) TO "); printer.printParameter(DatabaseCall.MAXROW_FIELD); call.setIgnoreFirstRowMaxResultsSettings(true); }
/** * Print the pagination SQL using FB syntax " ROWS {@literal <max> TO <first>}". */ @Override public void printSQLSelectStatement(DatabaseCall call, ExpressionSQLPrinter printer, SQLSelectStatement statement) { int max = 0; int firstRow = 0; if (statement.getQuery() != null) { max = statement.getQuery().getMaxRows(); firstRow = statement.getQuery().getFirstResult(); } // Both must be set, otherwise if one is set next, the old cached SQL would be used. if (!shouldUseRownumFiltering() || (max <= 0) || (firstRow <= 0)) { super.printSQLSelectStatement(call, printer, statement); return; } statement.setUseUniqueFieldAliases(true); call.setFields(statement.printSQL(printer)); printer.printString(" ROWS ("); printer.printParameter(DatabaseCall.FIRSTRESULT_FIELD); printer.printString(" + 1) TO "); printer.printParameter(DatabaseCall.MAXROW_FIELD); call.setIgnoreFirstRowSetting(true); call.setIgnoreMaxResultsSetting(true); }
/** * Print the pagination SQL using FB syntax " ROWS {@literal <max> TO <first>}". */ @Override public void printSQLSelectStatement(DatabaseCall call, ExpressionSQLPrinter printer, SQLSelectStatement statement) { int max = 0; int firstRow = 0; if (statement.getQuery() != null) { max = statement.getQuery().getMaxRows(); firstRow = statement.getQuery().getFirstResult(); } // Both must be set, otherwise if one is set next, the old cached SQL would be used. if (!shouldUseRownumFiltering() || (max <= 0) || (firstRow <= 0)) { super.printSQLSelectStatement(call, printer, statement); return; } statement.setUseUniqueFieldAliases(true); call.setFields(statement.printSQL(printer)); printer.printString(" ROWS ("); printer.printParameter(DatabaseCall.FIRSTRESULT_FIELD); printer.printString(" + 1) TO "); printer.printParameter(DatabaseCall.MAXROW_FIELD); call.setIgnoreFirstRowSetting(true); call.setIgnoreMaxResultsSetting(true); }
@Override public void printSQLSelectStatement(DatabaseCall call, ExpressionSQLPrinter printer, SQLSelectStatement statement) { int max = 0; int firstRow = 0; if (statement.getQuery() != null) { max = statement.getQuery().getMaxRows(); firstRow = statement.getQuery().getFirstResult(); } if (max <= 0 || !(this.shouldUseRownumFiltering())) { super.printSQLSelectStatement(call, printer, statement); statement.appendForUpdateClause(printer); return; } statement.setUseUniqueFieldAliases(true); call.setFields(statement.printSQL(printer)); printer.printString(LIMIT); printer.printParameter(DatabaseCall.FIRSTRESULT_FIELD); printer.printString(", "); printer.printParameter(DatabaseCall.MAXROW_FIELD); statement.appendForUpdateClause(printer); call.setIgnoreFirstRowSetting(true); call.setIgnoreMaxResultsSetting(true); }
firstRow = statement.getQuery().getFirstResult();
if (statement.getQuery()!=null){ max = statement.getQuery().getMaxRows(); firstRow = statement.getQuery().getFirstResult();
firstRow = statement.getQuery().getFirstResult();
firstRow = statement.getQuery().getFirstResult();
if (statement.getQuery()!=null){ max = statement.getQuery().getMaxRows(); firstRow = statement.getQuery().getFirstResult();