@Test public void testLimitOffsetNoOrderBy() { a(dialect.formSelect("people", null, null, new ArrayList<String>(), 1, 1)).shouldBeEqual( "SELECT * FROM (SELECT t2.*, ROWNUM AS oracle_row_number FROM (" + "SELECT * FROM people" + ") t2) WHERE oracle_row_number >= 2 AND ROWNUM <= 1"); a(dialect.formSelect("people", null, "last_name = ?", new ArrayList<String>(), 1, 10)).shouldBeEqual( "SELECT * FROM (SELECT t2.*, ROWNUM AS oracle_row_number FROM (" + "SELECT * FROM people WHERE last_name = ?" + ") t2) WHERE oracle_row_number >= 11 AND ROWNUM <= 1"); }
@Override public String formSelect(String tableName, String[] columns, String subQuery, List<String> orderBys, long limit, long offset) { boolean needLimit = limit != -1L; boolean needOffset = offset != -1L; StringBuilder fullQuery = new StringBuilder(); if (needOffset) { fullQuery.append("SELECT * FROM (SELECT t2.*, ROWNUM AS oracle_row_number FROM ("); } else if (needLimit) { fullQuery.append("SELECT * FROM (SELECT t2.* FROM ("); } appendSelect(fullQuery, tableName, columns, null, subQuery, orderBys); if (needOffset) { fullQuery.append(") t2) WHERE oracle_row_number >= ").append(offset + 1); if (needLimit) { fullQuery.append(" AND ROWNUM <= ").append(limit); } } else if (needLimit) { fullQuery.append(") t2) WHERE ROWNUM <= ").append(limit); } return fullQuery.toString(); }
OracleDialect extends DefaultDialect { @Override public String formSelect(String tableName, String[] columns, String subQuery, List<String> orderBys, long limit, long offset) { boolean needLimit = limit != -1L; boolean needOffset = offset != -1L; StringBuilder fullQuery = new StringBuilder(); if (needOffset) { fullQuery.append("SELECT * FROM (SELECT t2.*, ROWNUM AS oracle_row_number FROM ("); } else if (needLimit) { fullQuery.append("SELECT * FROM (SELECT t2.* FROM ("); } appendSelect(fullQuery, tableName, columns, null, subQuery, orderBys); if (needOffset) { fullQuery.append(") t2) WHERE oracle_row_number >= ").append(offset + 1); if (needLimit) { fullQuery.append(" AND ROWNUM <= ").append(limit); } } else if (needLimit) { fullQuery.append(") t2) WHERE ROWNUM <= ").append(limit); } return fullQuery.toString(); } }
OracleDialect extends DefaultDialect { @Override public String formSelect(String tableName, String[] columns, String subQuery, List<String> orderBys, long limit, long offset) { boolean needLimit = limit != -1L; boolean needOffset = offset != -1L; StringBuilder fullQuery = new StringBuilder(); if (needOffset) { fullQuery.append("SELECT * FROM (SELECT t2.*, ROWNUM AS oracle_row_number FROM ("); } else if (needLimit) { fullQuery.append("SELECT * FROM (SELECT t2.* FROM ("); } appendSelect(fullQuery, tableName, columns, null, subQuery, orderBys); if (needOffset) { fullQuery.append(") t2) WHERE oracle_row_number >= ").append(offset + 1); if (needLimit) { fullQuery.append(" AND ROWNUM <= ").append(limit); } } else if (needLimit) { fullQuery.append(") t2) WHERE ROWNUM <= ").append(limit); } return fullQuery.toString(); }  }
OracleDialect extends DefaultDialect { @Override public String formSelect(String tableName, String[] columns, String subQuery, List<String> orderBys, long limit, long offset) { boolean needLimit = limit != -1L; boolean needOffset = offset != -1L; StringBuilder fullQuery = new StringBuilder(); if (needOffset) { fullQuery.append("SELECT * FROM (SELECT t2.*, ROWNUM AS oracle_row_number FROM ("); } else if (needLimit) { fullQuery.append("SELECT * FROM (SELECT t2.* FROM ("); } appendSelect(fullQuery, tableName, columns, null, subQuery, orderBys); if (needOffset) { fullQuery.append(") t2) WHERE oracle_row_number >= ").append(offset + 1); if (needLimit) { fullQuery.append(" AND ROWNUM <= ").append(limit); } } else if (needLimit) { fullQuery.append(") t2) WHERE ROWNUM <= ").append(limit); } return fullQuery.toString(); }  @Override String formSelect(String tableName, String[] columns, String subQuery, List<String> orderBys, long limit, long offset); @Override Object overrideDriverTypeConversion(MetaModel mm, String attributeName, Object value); }
OracleDialect extends DefaultDialect { @Override public String formSelect(String tableName, String[] columns, String subQuery, List<String> orderBys, long limit, long offset) { boolean needLimit = limit != -1L; boolean needOffset = offset != -1L; StringBuilder fullQuery = new StringBuilder(); if (needOffset) { fullQuery.append("SELECT * FROM (SELECT t2.*, ROWNUM AS oracle_row_number FROM ("); } else if (needLimit) { fullQuery.append("SELECT * FROM (SELECT t2.* FROM ("); } appendSelect(fullQuery, tableName, columns, null, subQuery, orderBys); if (needOffset) { fullQuery.append(") t2) WHERE oracle_row_number >= ").append(offset + 1); if (needLimit) { fullQuery.append(" AND ROWNUM <= ").append(limit); } } else if (needLimit) { fullQuery.append(") t2) WHERE ROWNUM <= ").append(limit); } return fullQuery.toString(); }  @Override String formSelect(String tableName, String[] columns, String subQuery, List<String> orderBys, long limit, long offset); @Override Object overrideDriverTypeConversion(MetaModel mm, String attributeName, Object value);  }