/** * Some dialect-specific LIMIT clauses require the maximium last row number, * others require the maximum returned row count. */ private static int getMaxOrLimit(final RowSelection selection, final Dialect dialect) { final int firstRow = getFirstRow( selection ); final int lastRow = selection.getMaxRows().intValue(); if ( dialect.useMaxForLimit() ) { return lastRow + firstRow; } else { return lastRow; } }
/** * Use JDBC API to limit the number of rows returned by the SQL query if necessary */ private void setMaxRows( final PreparedStatement st, final RowSelection selection) throws SQLException { if ( hasMaxRows( selection ) ) { st.setMaxRows( selection.getMaxRows().intValue() + getFirstRow( selection ) ); } }
/** * Use JDBC API to limit the number of rows returned by the SQL query if necessary */ private void setMaxRows(final PreparedStatement st, final RowSelection selection) throws SQLException { if ( hasMaxRows( selection ) ) { st.setMaxRows( selection.getMaxRows().intValue() + getFirstRow( selection ) ); } }
/** * Advance the cursor to the first required row of the <tt>ResultSet</tt> */ private void advance(final ResultSet rs, final RowSelection selection) throws SQLException { final int firstRow = getFirstRow( selection ); if ( firstRow != 0 ) { if ( getFactory().getSettings().isScrollableResultSetsEnabled() ) { // we can go straight to the first required row rs.absolute( firstRow ); } else { // we need to step through the rows one row at a time (slow) for ( int m = 0; m < firstRow; m++ ) rs.next(); } } }
/** * Advance the cursor to the first required row of the <tt>ResultSet</tt> */ private void advance(final ResultSet rs, final RowSelection selection) throws SQLException { final int firstRow = getFirstRow( selection ); if ( firstRow != 0 ) { if ( getFactory().getSettings().isScrollableResultSetsEnabled() ) { // we can go straight to the first required row rs.absolute( firstRow ); } else { // we need to step through the rows one row at a time (slow) for ( int m = 0; m < firstRow; m++ ) rs.next(); } } }
/** * Advance the cursor to the first required row of the <tt>ResultSet</tt> */ private void advance(final ResultSet rs, final RowSelection selection) throws SQLException { final int firstRow = getFirstRow( selection ); if ( firstRow != 0 ) { if ( getFactory().getSettings().isScrollableResultSetsEnabled() ) { // we can go straight to the first required row rs.absolute( firstRow ); } else { // we need to step through the rows one row at a time (slow) for ( int m = 0; m < firstRow; m++ ) rs.next(); } } }
/** * Advance the cursor to the first required row of the <tt>ResultSet</tt> */ private void advance(final ResultSet rs, final RowSelection selection) throws SQLException { final int firstRow = getFirstRow( selection ); if ( firstRow != 0 ) { if ( getFactory().getSettings().isScrollableResultSetsEnabled() ) { // we can go straight to the first required row rs.absolute( firstRow ); } else { // we need to step through the rows one row at a time (slow) for ( int m = 0; m < firstRow; m++ ) rs.next(); } } }
/** * Some dialect-specific LIMIT clauses require the maximum last row number * (aka, first_row_number + total_row_count), while others require the maximum * returned row count (the total maximum number of rows to return). * * @param selection The selection criteria * @param dialect The dialect * @return The appropriate value to bind into the limit clause. */ private static int getMaxOrLimit(final RowSelection selection, final Dialect dialect) { final int firstRow = dialect.convertToFirstRowValue( getFirstRow( selection ) ); final int lastRow = selection.getMaxRows(); return dialect.useMaxForLimit() ? lastRow + firstRow : lastRow; }
/** * Some dialect-specific LIMIT clauses require the maximum last row number * (aka, first_row_number + total_row_count), while others require the maximum * returned row count (the total maximum number of rows to return). * * @param selection The selection criteria * @param dialect The dialect * @return The appropriate value to bind into the limit clause. */ private static int getMaxOrLimit(final RowSelection selection, final Dialect dialect) { final int firstRow = dialect.convertToFirstRowValue( getFirstRow( selection ) ); final int lastRow = selection.getMaxRows(); return dialect.useMaxForLimit() ? lastRow + firstRow : lastRow; }
/** * Use JDBC API to limit the number of rows returned by the SQL query if necessary */ private void setMaxRows( final PreparedStatement st, final RowSelection selection) throws SQLException { if ( hasMaxRows( selection ) ) { st.setMaxRows( selection.getMaxRows() + interpretFirstRow( getFirstRow( selection ) ) ); } }
/** * Use JDBC API to limit the number of rows returned by the SQL query if necessary */ private void setMaxRows( final PreparedStatement st, final RowSelection selection) throws SQLException { if ( hasMaxRows( selection ) ) { st.setMaxRows( selection.getMaxRows() + interpretFirstRow( getFirstRow( selection ) ) ); } }
/** * Bind parameters needed by the dialect-specific LIMIT clause */ private int bindLimitParameters(final PreparedStatement st, final int index, final RowSelection selection) throws SQLException { Dialect dialect = getFactory().getDialect(); if ( !dialect.supportsVariableLimit() ) return 0; if ( !hasMaxRows( selection ) ) throw new AssertionFailure( "no max results set" ); int firstRow = getFirstRow( selection ); int lastRow = getMaxOrLimit( selection, dialect ); boolean hasFirstRow = firstRow > 0 && dialect.supportsLimitOffset(); boolean reverse = dialect.bindLimitParametersInReverseOrder(); if ( hasFirstRow ) st.setInt( index + ( reverse ? 1 : 0 ), firstRow ); st.setInt( index + ( reverse || !hasFirstRow ? 0 : 1 ), lastRow ); return hasFirstRow ? 2 : 1; }
/** * Bind parameter values needed by the dialect-specific LIMIT clause. * * @param statement The statement to which to bind limit param values. * @param index The bind position from which to start binding * @param selection The selection object containing the limit information. * @return The number of parameter values bound. * @throws java.sql.SQLException Indicates problems binding parameter values. */ private int bindLimitParameters( final PreparedStatement statement, final int index, final RowSelection selection) throws SQLException { Dialect dialect = getFactory().getDialect(); if ( !dialect.supportsVariableLimit() ) { return 0; } if ( !hasMaxRows( selection ) ) { throw new AssertionFailure( "no max results set" ); } int firstRow = getFirstRow( selection ); int lastRow = getMaxOrLimit( selection, dialect ); boolean hasFirstRow = firstRow > 0 && dialect.supportsLimitOffset(); boolean reverse = dialect.bindLimitParametersInReverseOrder(); if ( hasFirstRow ) { statement.setInt( index + ( reverse ? 1 : 0 ), firstRow ); } statement.setInt( index + ( reverse || !hasFirstRow ? 0 : 1 ), lastRow ); return hasFirstRow ? 2 : 1; }
/** * Bind parameter values needed by the dialect-specific LIMIT clause. * * @param statement The statement to which to bind limit param values. * @param index The bind position from which to start binding * @param selection The selection object containing the limit information. * @return The number of parameter values bound. * @throws java.sql.SQLException Indicates problems binding parameter values. */ private int bindLimitParameters( final PreparedStatement statement, final int index, final RowSelection selection) throws SQLException { Dialect dialect = getFactory().getDialect(); if ( !dialect.supportsVariableLimit() ) { return 0; } if ( !hasMaxRows( selection ) ) { throw new AssertionFailure( "no max results set" ); } int firstRow = interpretFirstRow( getFirstRow( selection ) ); int lastRow = getMaxOrLimit( selection, dialect ); boolean hasFirstRow = dialect.supportsLimitOffset() && ( firstRow > 0 || dialect.forceLimitUsage() ); boolean reverse = dialect.bindLimitParametersInReverseOrder(); if ( hasFirstRow ) { statement.setInt( index + ( reverse ? 1 : 0 ), firstRow ); } statement.setInt( index + ( reverse || !hasFirstRow ? 0 : 1 ), lastRow ); return hasFirstRow ? 2 : 1; }
/** * Bind parameter values needed by the dialect-specific LIMIT clause. * * @param statement The statement to which to bind limit param values. * @param index The bind position from which to start binding * @param selection The selection object containing the limit information. * @return The number of parameter values bound. * @throws java.sql.SQLException Indicates problems binding parameter values. */ private int bindLimitParameters( final PreparedStatement statement, final int index, final RowSelection selection) throws SQLException { Dialect dialect = getFactory().getDialect(); if ( !dialect.supportsVariableLimit() ) { return 0; } if ( !hasMaxRows( selection ) ) { throw new AssertionFailure( "no max results set" ); } int firstRow = interpretFirstRow( getFirstRow( selection ) ); int lastRow = getMaxOrLimit( selection, dialect ); boolean hasFirstRow = dialect.supportsLimitOffset() && ( firstRow > 0 || dialect.forceLimitUsage() ); boolean reverse = dialect.bindLimitParametersInReverseOrder(); if ( hasFirstRow ) { statement.setInt( index + ( reverse ? 1 : 0 ), firstRow ); } statement.setInt( index + ( reverse || !hasFirstRow ? 0 : 1 ), lastRow ); return hasFirstRow ? 2 : 1; }
final RowSelection selection = queryParameters.getRowSelection(); boolean useLimit = useLimit( selection, dialect ); boolean hasFirstRow = getFirstRow( selection ) > 0; boolean useOffset = hasFirstRow && useLimit && dialect.supportsLimitOffset(); boolean callable = queryParameters.isCallable(); sql = dialect.getLimitString( useOffset ? getFirstRow(selection) : 0, getMaxOrLimit(selection, dialect) );
final RowSelection selection = queryParameters.getRowSelection(); boolean useLimit = useLimit( selection, dialect ); boolean hasFirstRow = getFirstRow( selection ) > 0; boolean useLimitOffset = hasFirstRow && useLimit && dialect.supportsLimitOffset(); boolean callable = queryParameters.isCallable(); sql = dialect.getLimitString( useLimitOffset ? getFirstRow(selection) : 0, getMaxOrLimit(selection, dialect) );
final RowSelection selection = queryParameters.getRowSelection(); boolean useLimit = useLimit( selection, dialect ); boolean hasFirstRow = getFirstRow( selection ) > 0; boolean useLimitOffset = hasFirstRow && useLimit && dialect.supportsLimitOffset(); boolean callable = queryParameters.isCallable(); sql = dialect.getLimitString( useLimitOffset ? getFirstRow(selection) : 0, getMaxOrLimit(selection, dialect) );