Пример #1
0
  @Override
  public long getRowCount(Session session) {
    StatementBuilder sql = new StatementBuilder("select count(*) from ");
    sql.append(getName());

    if (session == null) session = getDatabase().getSystemSession();
    Prepared prepared = session.prepare(sql.toString(), true);
    prepared.setLocal(false);
    ResultInterface result = prepared.query(0);
    return result.getRowCount();
  }
Пример #2
0
  private Cursor find(Session session, SearchRow first, boolean bigger, SearchRow last) {
    StatementBuilder sql = new StatementBuilder("select _gui_row_id_");
    for (Column c : getColumns()) {
      sql.append(",");
      sql.append(c.getName());
    }
    sql.append(" from ").append(getName());

    if (first != null || last != null) {
      sql.append(" where ");

      for (Column c : getColumns()) {
        sql.appendExceptFirst(" and ");
        if (first != null) {
          sql.append(c.getName()).append(">=");
          Value v = first.getValue(c.getColumnId());
          if (v != null) {
            sql.append(v.getSQL());
          }
        }
        if (last != null) {
          sql.append(c.getName()).append("<=");
          Value v = last.getValue(c.getColumnId());
          if (v != null) {
            sql.append(v.getSQL());
          }
        }
      }
    }

    Prepared prepared = session.prepare(sql.toString(), true);
    prepared.setLocal(false);
    ResultInterface result = prepared.query(0);
    if (bigger) result.next();
    return new GlobalUniqueIndexTableCursor(result);
  }