]> SALOME platform Git repositories - tools/siman.git/blobdiff - Workspace/Siman-Common/src/org/splat/dal/bo/kernel/Persistent.java
Salome HOME
Id now is Long instead of Integer. First unit test is created. hibernate-3.5.jar...
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / dal / bo / kernel / Persistent.java
index 8ceda827edad4f4962f2edb3c0fb04db277f31c2..11aa5c432a6d7a64cda966e270d8ec2a05c7cd07 100644 (file)
@@ -36,7 +36,7 @@ import org.splat.kernel.ObjectProperties;
 
 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 {
 //  ----------------------------------------------------------------------
@@ -83,8 +83,8 @@ public abstract class Persistent {
       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);
       }
@@ -98,11 +98,19 @@ public abstract class Persistent {
  * @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();
@@ -126,7 +134,7 @@ public abstract class Persistent {
  */
     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();
     }