db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb release-notes.txt
Date Fri, 26 Nov 2004 19:32:07 GMT
arminw      2004/11/26 11:32:06

  Modified:    src/java/org/apache/ojb/broker/accesslayer Tag:
                        OJB_1_0_RELEASE JdbcAccessImpl.java
               src/java/org/apache/ojb/broker/core Tag: OJB_1_0_RELEASE
                        PersistenceBrokerImpl.java
               src/java/org/apache/ojb/broker/metadata Tag: OJB_1_0_RELEASE
                        ClassDescriptor.java
               src/test/org/apache/ojb/broker/sequence Tag: OJB_1_0_RELEASE
                        NativeIdentifierTest.java
               .        Tag: OJB_1_0_RELEASE release-notes.txt
  Log:
  move PK assignment when using database identity columns from PBImpl to JdbcAccessImpl,
  remove 1:1 FK assignment in SequenceManagerNativeImpl and method call in PBImpl
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.22.2.1  +11 -4     db-ojb/src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java
  
  Index: JdbcAccessImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java,v
  retrieving revision 1.22
  retrieving revision 1.22.2.1
  diff -u -r1.22 -r1.22.2.1
  --- JdbcAccessImpl.java	23 Apr 2004 18:36:20 -0000	1.22
  +++ JdbcAccessImpl.java	26 Nov 2004 19:32:06 -0000	1.22.2.1
  @@ -19,6 +19,7 @@
   import java.sql.PreparedStatement;
   import java.sql.ResultSet;
   import java.sql.SQLException;
  +import java.sql.Statement;
   import java.util.HashMap;
   import java.util.Iterator;
   import java.util.Map;
  @@ -38,6 +39,7 @@
   import org.apache.ojb.broker.query.Query;
   import org.apache.ojb.broker.util.logging.Logger;
   import org.apache.ojb.broker.util.logging.LoggerFactory;
  +import org.apache.ojb.broker.util.sequence.SequenceManagerException;
   
   /**
    * JdbcAccess is responsible for establishing performing
  @@ -196,16 +198,21 @@
                   logger.debug("executeInsert: " + stmt);
   
               stmt.executeUpdate();
  +            // if database Identity Columns are used, query the id from database
  +            // other SequenceManager implementations will ignore this call
  +            broker.serviceSequenceManager().afterStore(this, cld, obj);
   
               // Harvest any return values.
               harvestReturnValues(cld.getInsertProcedure(), obj, stmt);
           }
           catch (PersistenceBrokerException e)
           {
  -            logger.error(
  -                "PersistenceBrokerException during the execution of the insert: " + e.getMessage(),
  -                e);
  +            logger.error("PersistenceBrokerException during the execution of the insert:
" + e.getMessage(), e);
               throw e;
  +        }
  +        catch(SequenceManagerException e)
  +        {
  +            throw new PersistenceBrokerException("Can't lookup new database Identity Column
value", e);
           }
           catch (SQLException e)
           {
  
  
  
  No                   revision
  No                   revision
  1.83.2.8  +1 -23     db-ojb/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java
  
  Index: PersistenceBrokerImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java,v
  retrieving revision 1.83.2.7
  retrieving revision 1.83.2.8
  diff -u -r1.83.2.7 -r1.83.2.8
  --- PersistenceBrokerImpl.java	7 Oct 2004 16:57:38 -0000	1.83.2.7
  +++ PersistenceBrokerImpl.java	26 Nov 2004 19:32:06 -0000	1.83.2.8
  @@ -68,7 +68,6 @@
   import org.apache.ojb.broker.util.logging.Logger;
   import org.apache.ojb.broker.util.logging.LoggerFactory;
   import org.apache.ojb.broker.util.sequence.SequenceManager;
  -import org.apache.ojb.broker.util.sequence.SequenceManagerException;
   import org.apache.ojb.broker.util.sequence.SequenceManagerFactory;
   
   /**
  @@ -1646,16 +1645,6 @@
               }
           }
   
  -        // setreferenceFKs for auto_inc dbs - this can be ignored by hi low or any that
do pre assignment
  -        try
  -        {
  -            sequenceManager.setReferenceFKs(obj, cld);
  -        }
  -        catch (SequenceManagerException e)
  -        {
  -            logger.error("Setting of reference FK failed", e);
  -            throw new PersistenceBrokerException(e);
  -        }
           // get super class cld then store it with the object
           /*
           now for multiple table inheritance
  @@ -1680,17 +1669,6 @@
           if (insert)
           {
               dbAccess.executeInsert(cld, obj);
  -            // Let SequenceManager update id if necessary, should only happen after an
insert
  -            try
  -            {
  -                sequenceManager.afterStore(dbAccess, cld, obj);
  -            }
  -            catch (SequenceManagerException e)
  -            {
  -                logger.error("SQLException during SequenceManager.afterStore call on object
'"
  -                        + cld.getClassOfObject().getName() + "': " + e.getMessage(), e);
  -                throw new PersistenceBrokerException(e);
  -            }
           }
           // else use UPDATE
           else
  
  
  
  No                   revision
  No                   revision
  1.88.2.2  +29 -2     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.88.2.1
  retrieving revision 1.88.2.2
  diff -u -r1.88.2.1 -r1.88.2.2
  --- ClassDescriptor.java	11 Nov 2004 14:17:46 -0000	1.88.2.1
  +++ ClassDescriptor.java	26 Nov 2004 19:32:06 -0000	1.88.2.2
  @@ -140,6 +140,8 @@
        * of these must be present for this function to be successful.
        */
       private Class factoryClass;
  +    private int useIdentityColumn = 0;
  +
       private String baseClass = null;
       /**
        * transaction isolation level specified for this class, used in the ODMG server
  @@ -938,7 +940,7 @@
                   {
                       long newCv = (new Date()).getTime();
                       Timestamp ts = new Timestamp(newCv);
  -                    ts.setNanos(0);
  +                    ts.setNanos(((int) (ts.getNanos() / 1000000)) * 1000000);
                       f.set(obj, ts);
                   }
               }
  @@ -2104,4 +2106,29 @@
       {
   		return persistentFieldClassName;
       }
  +
  +    /**
  +     * Returns <em>true</em> if an DB Identity column field based sequence
  +     * manager was used. In that cases we will find an autoincrement field with
  +     * read-only access and return true, otherwise false.
  +     */
  +     public boolean useIdentityColumnField()
  +     {
  +         if(useIdentityColumn == 0)
  +         {
  +             useIdentityColumn = -1;
  +             FieldDescriptor[] pkFields = getPkFields();
  +             for (int i = 0; i < pkFields.length; i++)
  +             {
  +                 // to find the identity column we search for a autoincrement
  +                 // read-only field
  +                if (pkFields[i].isAutoIncrement() && pkFields[i].isAccessReadOnly())
  +                {
  +                    useIdentityColumn = 1;
  +                    break;
  +                }
  +             }
  +         }
  +        return useIdentityColumn == 1;
  +     }
   }
  
  
  
  No                   revision
  No                   revision
  1.10.2.4  +14 -5     db-ojb/src/test/org/apache/ojb/broker/sequence/NativeIdentifierTest.java
  
  Index: NativeIdentifierTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/sequence/NativeIdentifierTest.java,v
  retrieving revision 1.10.2.3
  retrieving revision 1.10.2.4
  diff -u -r1.10.2.3 -r1.10.2.4
  --- NativeIdentifierTest.java	2 Aug 2004 19:12:04 -0000	1.10.2.3
  +++ NativeIdentifierTest.java	26 Nov 2004 19:32:06 -0000	1.10.2.4
  @@ -602,9 +602,7 @@
           obj_1.addReference(ref_4);
   
           obj_1.setSingleReference(s_ref_3);
  -        s_ref_3.setMainObject(obj_1);
           obj_2.setSingleReference(s_ref_4);
  -        s_ref_3.setMainObject(obj_1);
   
           Implementation odmg = OJB.getInstance();
           Database db = odmg.newDatabase();
  @@ -1031,7 +1029,9 @@
   
           public String toString()
           {
  -            return ToStringBuilder.reflectionToString(this);
  +            return new ToStringBuilder(this).append("identifier", identifier).append("name",
name)
  +                    .append("allReferences", allReferences != null ? allReferences.toString()
: "null")
  +                    .append("singleReference", singleReference.getClass().toString()).toString();
           }
       }
   
  @@ -1091,6 +1091,12 @@
           {
               this.name = name;
           }
  +
  +        public String toString()
  +        {
  +            return new ToStringBuilder(this).append("id", id).append("name", name)
  +                    .append("mainObject", mainObject != null ? mainObject.getClass().toString()
: "null").toString();
  +        }
       }
   
       public static interface CollectionReferenceIF extends Serializable
  @@ -1164,7 +1170,10 @@
   
           public String toString()
           {
  -            return ToStringBuilder.reflectionToString(this);
  +            return new ToStringBuilder(this).append("id", refIdentifier).append("name",
refName)
  +                    .append("fkIdentifier", fkIdentifier)
  +                    .append("singleReference", singleReference != null ? singleReference.toString()
: "null")
  +                    .toString();
           }
       }
   }
  
  
  
  No                   revision
  No                   revision
  1.54.2.19 +4 -1      db-ojb/release-notes.txt
  
  Index: release-notes.txt
  ===================================================================
  RCS file: /home/cvs/db-ojb/release-notes.txt,v
  retrieving revision 1.54.2.18
  retrieving revision 1.54.2.19
  diff -u -r1.54.2.18 -r1.54.2.19
  --- release-notes.txt	22 Nov 2004 21:35:57 -0000	1.54.2.18
  +++ release-notes.txt	26 Nov 2004 19:32:06 -0000	1.54.2.19
  @@ -38,6 +38,9 @@
     the mapped classes.
   - Introduce new locking-package in kernel api, adapt odmg-locking stuff and remove unused
     classes from org.apache.ojb.odmg.locking package.
  +- Use of database identity column (SequenceManagerNativeImpl). Move assign of PK values
from
  +  PersistenceBrokerImpl to JdbcAccessImpl#executeInsert. Remove usage of SequenceManager#setReferenceFKs,
  +  will be handled by OJB in same way as without usage of database identity column.
   
   BUG FIXES:
   Please refer to our Bug tracking site (http://issues.apache.org/scarab/servlet/scarab/)
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message