if (MODIFIED.equals(indexedProperty)) {
t += " and MODIFIED >= ?";
}
else if (NodeDocument.HAS_BINARY_FLAG.equals(indexedProperty)) {
if (startValue != NodeDocument.HAS_BINARY_VAL) {
throw new DocumentStoreException("unsupported value for property " + NodeDocument.HAS_BINARY_FLAG);
}
t += " and HASBINARY = 1";
}
}
t += " order by ID";
if (limit != Integer.MAX_VALUE) {
t += this.needsLimit ? (" LIMIT " + limit) : (" FETCH FIRST " + limit + " ROWS ONLY");
}
PreparedStatement stmt = connection.prepareStatement(t);
List<RDBRow> result = new ArrayList<RDBRow>();
try {
int si = 1;
stmt.setString(si++, minId);
stmt.setString(si++, maxId);
if (MODIFIED.equals(indexedProperty)) {
stmt.setLong(si++, startValue);
}
if (limit != Integer.MAX_VALUE) {
stmt.setFetchSize(limit);
}
ResultSet rs = stmt.executeQuery();
while (rs.next() && result.size() < limit) {
String id = rs.getString(1);
if (id.compareTo(minId) < 0 || id.compareTo(maxId) > 0) {
throw new DocumentStoreException("unexpected query result: '" + minId + "' < '" + id + "' < '" + maxId + "' - broken DB collation?");
}
long modified = rs.getLong(2);
long modcount = rs.getLong(3);
String data = rs.getString(4);
byte[] bdata = rs.getBytes(5);