db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject cvs commit: db-ojb/src/test/org/apache/ojb repository.dtd
Date Thu, 03 Apr 2003 20:35:28 GMT
thma        2003/04/03 12:35:27

  Modified:    src/test/org/apache/ojb/quick-db OJB.script OJB.properties
               src/java/org/apache/ojb/broker/metadata RepositoryTags.java
                        ClassDescriptor.java RepositoryXmlHandler.java
                        FieldDescriptor.java RepositoryElements.java
               src/test/org/apache/ojb repository.dtd
  Log:
  applying David Warnocks optimistic locking extensions
  
  Revision  Changes    Path
  1.16      +1 -1      db-ojb/src/test/org/apache/ojb/quick-db/OJB.script
  
  Index: OJB.script
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/quick-db/OJB.script,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- OJB.script	14 Mar 2003 20:07:17 -0000	1.15
  +++ OJB.script	3 Apr 2003 20:35:26 -0000	1.16
  @@ -70,7 +70,7 @@
   CREATE TABLE COLLECTION_GATHERER(GAT_ID INTEGER NOT NULL PRIMARY KEY,NAME VARCHAR(150))
   CREATE TABLE COLLECTION_COLLECTIBLE_A(COL_ID INTEGER NOT NULL PRIMARY KEY,NAME VARCHAR(150),GAT_ID
INTEGER)
   CREATE TABLE COLLECTION_COLLECTIBLE_BC(COL_ID INTEGER NOT NULL PRIMARY KEY,NAME VARCHAR(150),GAT_ID
INTEGER,EXTENT_NAME VARCHAR(150))
  -CREATE TABLE OJB_HL_SEQ(TABLENAME VARCHAR(175) NOT NULL,FIELDNAME VARCHAR(70) NOT NULL,MAX_KEY
INTEGER,GRAB_SIZE INTEGER,CONSTRAINT SYS_PK_OJB_HL_SEQ PRIMARY KEY(TABLENAME,FIELDNAME))
  +CREATE TABLE OJB_HL_SEQ(TABLENAME VARCHAR(175) NOT NULL,FIELDNAME VARCHAR(70) NOT NULL,MAX_KEY
INTEGER,GRAB_SIZE INTEGER,VERSION INTEGER,CONSTRAINT SYS_PK_OJB_HL_SEQ PRIMARY KEY(TABLENAME,FIELDNAME))
   CREATE TABLE OJB_LOCKENTRY(OID_ VARCHAR(250) NOT NULL,TX_ID VARCHAR(50) NOT NULL,TIMESTAMP_
TIMESTAMP,ISOLATIONLEVEL INTEGER,LOCKTYPE INTEGER,CONSTRAINT SYS_PK_OJB_LOCKENTRY PRIMARY
KEY(OID_,TX_ID))
   CREATE TABLE OJB_NRM(NAME VARCHAR(250) NOT NULL PRIMARY KEY,OID_ LONGVARBINARY)
   CREATE TABLE OJB_DLIST(ID INTEGER NOT NULL PRIMARY KEY,SIZE_ INTEGER)
  
  
  
  1.15      +1 -1      db-ojb/src/test/org/apache/ojb/quick-db/OJB.properties
  
  Index: OJB.properties
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/quick-db/OJB.properties,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- OJB.properties	14 Mar 2003 20:07:17 -0000	1.14
  +++ OJB.properties	3 Apr 2003 20:35:26 -0000	1.15
  @@ -1,5 +1,5 @@
   #HSQL database
  -#Fri Mar 14 20:11:26 CET 2003
  +#Thu Apr 03 21:09:19 CEST 2003
   sql.strict_fk=true
   readonly=false
   sql.strong_fk=true
  
  
  
  1.27      +1 -0      db-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryTags.java
  
  Index: RepositoryTags.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryTags.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- RepositoryTags.java	2 Apr 2003 20:22:32 -0000	1.26
  +++ RepositoryTags.java	3 Apr 2003 20:35:26 -0000	1.27
  @@ -151,6 +151,7 @@
           table.put("jndi-datasource-name", new Integer(DATASOURCE_NAME));
           table.put("jdbc-level", new Integer(JDBC_LEVEL));
           table.put("locking", new Integer(LOCKING));
  +        table.put("update-lock", new Integer(UPDATE_LOCK));
           table.put("refresh", new Integer(REFRESH_REFERENCE));
           table.put("proxy", new Integer(PROXY_REFERENCE));
           table.put("sort", new Integer(SORT));
  
  
  
  1.53      +31 -28    db-ojb/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java
  
  Index: ClassDescriptor.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java,v
  retrieving revision 1.52
  retrieving revision 1.53
  diff -u -r1.52 -r1.53
  --- ClassDescriptor.java	2 Apr 2003 07:40:50 -0000	1.52
  +++ ClassDescriptor.java	3 Apr 2003 20:35:26 -0000	1.53
  @@ -727,6 +727,7 @@
       /**
        * updates the values for locking fields , BRJ
        * handles int, long, Timestamp
  +     * respects updateLock so locking field are only updated when updateLock is true
        * @throws PersistenceBrokerException if there is an erros accessing obj field values
        */
       public void updateLockingValues(Object obj) throws PersistenceBrokerException
  @@ -735,40 +736,42 @@
           for (int i = 0; i < fields.length; i++)
           {
               FieldDescriptor fmd = fields[i];
  -            PersistentField f = fmd.getPersistentField();
  -            Object cv = null;
  -            cv = f.get(obj);
  +			if (fmd.isUpdateLock())
  +            {
  +                PersistentField f = fmd.getPersistentField();
  +                Object cv = null;
  +                cv = f.get(obj);
   
  -            // int
  -            if ((f.getType() == int.class) || (f.getType() == Integer.class))
  +                // int
  +                if ((f.getType() == int.class) || (f.getType() == Integer.class))
   
  -            {
  -                int newCv = 0;
  -                if (cv != null)
                   {
  -                    newCv = ((Number) cv).intValue();
  +                    int newCv = 0;
  +                    if (cv != null)
  +                    {
  +                        newCv = ((Number) cv).intValue();
  +                    }
  +                    newCv++;
  +                    f.set(obj, new Integer(newCv));
                   }
  -                newCv++;
  -                f.set(obj, new Integer(newCv));
  -            }
  -            // long
  -            else if ((f.getType() == long.class) || (f.getType() == Long.class))
  -
  -            {
  -                long newCv = 0;
  -                if (cv != null)
  +                // long
  +                else if ((f.getType() == long.class) || (f.getType() == Long.class))
                   {
  -                    newCv = ((Number) cv).longValue();
  +                    long newCv = 0;
  +                    if (cv != null)
  +                    {
  +                        newCv = ((Number) cv).longValue();
  +                    }
  +                    newCv++;
  +                    f.set(obj, new Long(newCv));
                   }
  -                newCv++;
  -                f.set(obj, new Long(newCv));
  -            }
  -            // Timestamp
  -            else if (f.getType() == Timestamp.class)
  +                // Timestamp
  +                else if (f.getType() == Timestamp.class)
   
  -            {
  -                long newCv = (new Date()).getTime();
  -                f.set(obj, new Timestamp(newCv));
  +                {
  +                    long newCv = (new Date()).getTime();
  +                    f.set(obj, new Timestamp(newCv));
  +                }
               }
           }
       }
  
  
  
  1.39      +6 -1      db-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryXmlHandler.java
  
  Index: RepositoryXmlHandler.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryXmlHandler.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- RepositoryXmlHandler.java	2 Apr 2003 20:22:32 -0000	1.38
  +++ RepositoryXmlHandler.java	3 Apr 2003 20:35:26 -0000	1.39
  @@ -386,6 +386,11 @@
                           b = (new Boolean(locking)).booleanValue();
                           m_CurrentFLD.setLocking(b);
   
  +                        String updateLock = atts.getValue(tags.getTagById(UPDATE_LOCK));
  +                        if (isDebug) logger.debug("     " + tags.getTagById(UPDATE_LOCK)
+ ": " + updateLock);
  +                        b = (new Boolean(updateLock)).booleanValue();
  +                        m_CurrentFLD.setUpdateLock(b);
  +
                           String fieldConversion = atts.getValue(tags.getTagById(FIELD_CONVERSION));
                           if (isDebug) logger.debug("     " + tags.getTagById(FIELD_CONVERSION)
+ ": " + fieldConversion);
                           if (fieldConversion != null)
  
  
  
  1.19      +38 -0     db-ojb/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java
  
  Index: FieldDescriptor.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- FieldDescriptor.java	2 Apr 2003 07:40:50 -0000	1.18
  +++ FieldDescriptor.java	3 Apr 2003 20:35:27 -0000	1.19
  @@ -97,6 +97,11 @@
       private FieldConversion fieldConversion = null;
       // true if field is used for optimistic locking BRJ
       private boolean locking = false;
  +    // if locking is true and updateLock is true then 
  +    // on save lock columns will be updated.
  +    // if false then it is the responsibility of the
  +    // dbms to update all lock columns eg using triggers
  +    private boolean updateLock = true;
   
       /**
        * returns a comparator that allows to sort a Vector of FieldMappingDecriptors
  @@ -387,6 +392,32 @@
           this.locking = locking;
       }
   
  +    /**
  +     * Gets the updateLock
  +     * updateLock controls whether the lock fields should be
  +     * updated by OJB when a row is saved
  +     * If false then the dbms needs to update the lock fields.
  +     * The default is true
  +     * @return Returns a boolean
  +     */
  +    public boolean isUpdateLock()
  +    {
  +        return updateLock;
  +    }
  +
  +    /**
  +     * Sets the updateLock
  +     * updateLock controls whether the lock fields should be
  +     * updated by OJB when a row is saved.
  +     * If false then the dbms needs to update the lock fields.
  +     * The default is true
  +     * @param updateLock The updateLock to set
  +     */
  +    public void setUpdateLock(boolean updateLock)
  +    {
  +        this.updateLock = updateLock;
  +    }
  +
       public void setLength(int length)
       {
           this.length = length;
  @@ -507,6 +538,13 @@
           if (this.isLocking())
           {
               result += "        " + tags.getAttribute(LOCKING, "true") + eol;
  +        }
  +
  +        // updateLock
  +        // default is true so only write if false
  +        if (!this.isUpdateLock())
  +        {
  +            result += "        " + tags.getAttribute(UPDATE_LOCK, "false") + eol;
           }
   
           // default-fetch not yet implemented
  
  
  
  1.25      +2 -1      db-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryElements.java
  
  Index: RepositoryElements.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryElements.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- RepositoryElements.java	2 Apr 2003 20:22:32 -0000	1.24
  +++ RepositoryElements.java	3 Apr 2003 20:35:27 -0000	1.25
  @@ -112,6 +112,7 @@
       public static final int DATASOURCE_NAME = 44;
       public static final int JDBC_LEVEL = 45;
       public static final int LOCKING = 46;
  +    public static final int UPDATE_LOCK = 98;
       public static final int REFRESH_REFERENCE = 47;
       public static final int PROXY_REFERENCE = 48;
       public static final int ISOLATION_LEVEL = 34;
  @@ -163,7 +164,7 @@
       public static final int NAME = 97;
   
       // maintain a next id to keep track where we are
  -    static final int _NEXT = 98;
  +    static final int _NEXT = 99;
       
   	// String constants
       public static final String TAG_ACCESS           = "access";
  
  
  
  1.40      +7 -0      db-ojb/src/test/org/apache/ojb/repository.dtd
  
  Index: repository.dtd
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/repository.dtd,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- repository.dtd	2 Apr 2003 07:40:49 -0000	1.39
  +++ repository.dtd	3 Apr 2003 20:35:27 -0000	1.40
  @@ -399,6 +399,12 @@
   	used for optimistic locking. can only be set for TIMESTAMP and INTEGER
   	columns.
   
  +	The updatelock attribute is set to false if the persistent attribute is
  +	used for optimistic locking AND the dbms should update the lock column
  +    itself. The default is true which means that when locking is true then
  +    OJB will update the locking fields. Can only be set for TIMESTAMP and INTEGER
  +	columns.
  +
   	The default-fetch attribute specifies whether the persistent attribute
   	belongs to the JDO default fetch group.
   
  @@ -441,6 +447,7 @@
   	autoincrement (true | false) "false"
       sequence-name CDATA #IMPLIED
   	locking (true | false) "false"
  +	update-lock (true | false) "true"
   	default-fetch (true | false) "false"
   	conversion CDATA #IMPLIED
   	length CDATA #IMPLIED
  
  
  

Mime
View raw message