/** Get more Id's by executing a query and reading the Id's returned. */
  protected ArrayList<Integer> getMoreIds(int loadSize, Transaction t) {

    String sql = getSql(loadSize);

    ArrayList<Integer> newIds = new ArrayList<Integer>(loadSize);

    boolean useTxnConnection = t != null;

    Connection c = null;
    PreparedStatement pstmt = null;
    ResultSet rset = null;
    try {
      c = useTxnConnection ? t.getConnection() : dataSource.getConnection();

      pstmt = c.prepareStatement(sql);
      rset = pstmt.executeQuery();
      while (rset.next()) {
        int val = rset.getInt(1);
        newIds.add(Integer.valueOf(val));
      }
      if (newIds.size() == 0) {
        String m = "Always expecting more than 1 row from " + sql;
        throw new PersistenceException(m);
      }

      return newIds;

    } catch (SQLException e) {
      if (e.getMessage().contains("Database is already closed")) {
        String msg = "Error getting SEQ when DB shutting down " + e.getMessage();
        logger.info(msg);
        System.out.println(msg);
        return newIds;
      } else {
        throw new PersistenceException("Error getting sequence nextval", e);
      }
    } finally {
      if (useTxnConnection) {
        closeResources(null, pstmt, rset);
      } else {
        closeResources(c, pstmt, rset);
      }
    }
  }