/** * Alters the varbinds to work with limitQuery. To use this, you must have created your * query with a limitQueryNoOffset call. This decoupling of the query creating and the varbinds * allows for the registration of limit queries. * * @see SQL#formatLimitQuery(String) */ public static void addVarbindsForLimitQuery(int maxRows, long offset, List<Object> varbinds, DBType dbType) { internalLimitQuery("", maxRows, offset, varbinds, dbType); //$NON-NLS-1$ }
/** * Limits the given query to the given number of maximum rows at * the given offset. This is effective when trying to page through * a set of results. This method does not alter the query directly, * it simply wraps it in sub-selects. * <p> * Note: you cannot alter the query or varbinds after calling this method. * * @param query - query to limit * @param maxRows - maximum number of results to provide * @param offset - 0-based offset to return results from * @param varbinds - the variable bindings for the given query */ public static String limitQuery(String query, int maxRows, int offset, List<Object> varbinds, DBType dbType) { return internalLimitQuery(query, maxRows, offset, varbinds, dbType); }
/** * Creates a query string for a limit query, but does not set the varbinds. * To use this, you will have to pass your varbinds through a limitQuery call. * query with a limitQuery call. This decoupling of the query creating and the varbinds * allows for the registration of limit queries. * <p> * This method has NoOffset in the name because it creates a limit query that * does not have an offset value. The presence of an offset could change the * resulting String. * * @see addVarbindsForLimitQuery */ public static String formatLimitQuery(String query, BasicSQL.OffsetInclusion offset, DBType dbType) { int fakeOffset; if (offset.equals(BasicSQL.OffsetInclusion.INCLUDE_OFFSET)) { //TODO (dcohen): comment why this fake offset causes the proper query to be created fakeOffset = 1; } else { fakeOffset = 0; } return internalLimitQuery(query, 1, fakeOffset, new ArrayList<Object>(), dbType); }
/** * Alters the varbinds to work with limitQuery. To use this, you must have created your * query with a limitQueryNoOffset call. This decoupling of the query creating and the varbinds * allows for the registration of limit queries. * * @see SQL#formatLimitQuery(String) */ public static void addVarbindsForLimitQuery(int maxRows, long offset, List<Object> varbinds, DBType dbType) { internalLimitQuery("", maxRows, offset, varbinds, dbType); //$NON-NLS-1$ }
/** * Limits the given query to the given number of maximum rows at * the given offset. This is effective when trying to page through * a set of results. This method does not alter the query directly, * it simply wraps it in sub-selects. * <p> * Note: you cannot alter the query or varbinds after calling this method. * * @param query - query to limit * @param maxRows - maximum number of results to provide * @param offset - 0-based offset to return results from * @param varbinds - the variable bindings for the given query */ public static String limitQuery(String query, int maxRows, int offset, List<Object> varbinds, DBType dbType) { return internalLimitQuery(query, maxRows, offset, varbinds, dbType); }
/** * Creates a query string for a limit query, but does not set the varbinds. * To use this, you will have to pass your varbinds through a limitQuery call. * query with a limitQuery call. This decoupling of the query creating and the varbinds * allows for the registration of limit queries. * <p> * This method has NoOffset in the name because it creates a limit query that * does not have an offset value. The presence of an offset could change the * resulting String. * * @see addVarbindsForLimitQuery */ public static String formatLimitQuery(String query, BasicSQL.OffsetInclusion offset, DBType dbType) { int fakeOffset; if (offset.equals(BasicSQL.OffsetInclusion.INCLUDE_OFFSET)) { //TODO (dcohen): comment why this fake offset causes the proper query to be created fakeOffset = 1; } else { fakeOffset = 0; } return internalLimitQuery(query, 1, fakeOffset, new ArrayList<Object>(), dbType); }