Пример #1
0
  public Object fetch(Object[] fields, Object identity)
      throws ObjectNotFoundException, PersistenceException {
    Object stamp = null;

    try {

      // Load all the fields of the object including one-one relations
      // index 0 belongs to the identity
      for (int i = 1; i < _sqlTypes.length; ++i)
        fields[i - 1] = SQLTypes.getObject(_rs, i + 1, _sqlTypes[i]);
      if (_rs.next()) _lastIdentity = SQLTypes.getObject(_rs, 1, _sqlTypes[0]);
      else _lastIdentity = null;
    } catch (SQLException except) {
      throw new PersistenceException(Messages.format("persist.nested", except));
    }
    return stamp;
  }
Пример #2
0
  public Object nextIdentity(Object identity) throws PersistenceException {
    try {
      if (_lastIdentity == null) {
        if (!_rs.next()) return null;
        _lastIdentity = SQLTypes.getObject(_rs, 1, _sqlTypes[0]);
        return new Complex(_lastIdentity);
      }

      while (_lastIdentity.equals(identity)) {
        if (!_rs.next()) {
          _lastIdentity = null;
          return null;
        }
        _lastIdentity = SQLTypes.getObject(_rs, 1, _sqlTypes[0]);
      }
      return new Complex(_lastIdentity);
    } catch (SQLException except) {
      _lastIdentity = null;
      throw new PersistenceException(Messages.format("persist.nested", except));
    }
  }