public abstract class Persistent {
- private int rid; // Primary key of persistent objects
+ private long rid; // Primary key of persistent objects
protected abstract static class Properties implements ObjectProperties {
// ----------------------------------------------------------------------
if (entity == null) return false;
if (entity.getClass().equals(this.getClass())) {
Persistent object = (Persistent)entity;
- int he = object.getIndex(); // getIndex() is supposed fetching the index if not yet done
- int me = this.getIndex(); // getIndex() is supposed fetching the index if not yet done
+ long he = object.getIndex(); // getIndex() is supposed fetching the index if not yet done
+ long me = this.getIndex(); // getIndex() is supposed fetching the index if not yet done
if (me*he != 0) return (he == me);
if (me+he == 0) return (this == object);
}
* @return the PID of this, or 0 if this is not saved.
* @see isSaved()
*/
- public int getIndex () {
+ public long getIndex () {
// ----------------------
return rid;
}
+ /**
+ * Set an id for the object.
+ * @param anId id to set
+ */
+ public void setIndex(long anId) {
+ rid = anId;
+ }
+
public int hashCode () {
// ----------------------
return toString().hashCode();
*/
public String toString () {
// -------------------------
- int oid = getIndex(); // getIndex() is supposed fetching the index if not yet done
+ long oid = getIndex(); // getIndex() is supposed fetching the index if not yet done
if (oid == 0) oid = super.hashCode(); //WARNING: Must not call super.toString() as it goes back here (this.toString())
return new StringBuffer("object ").append(getClass().getName()).append("@").append(oid).toString();
}