jmcnally    02/03/07 17:19:50

  Modified:    src/java/org/apache/torque/util BasePeer.java Criteria.java
  Log:
  The flag that was preventing the inefficiency of Criteria.containsObjectColumn
  from executing for any db except postgresql was removed.  So the code was
  being run for all databases and it was likely not even used in postgres and
  even less likely needed in any other db.
  
  The method's use in BasePeer is replaced by a simple flag that one will need
  to set manually, if one is using postgres's oid type.  Or if there is any
  other reason to set a transaction.
  
  Revision  Changes    Path
  1.30      +6 -6      
jakarta-turbine-torque/src/java/org/apache/torque/util/BasePeer.java
  
  Index: BasePeer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/util/BasePeer.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- BasePeer.java     6 Mar 2002 15:12:25 -0000       1.29
  +++ BasePeer.java     8 Mar 2002 01:19:50 -0000       1.30
  @@ -115,7 +115,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Frank Y. Kim</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>John D. McNally</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Brett McLaughlin</a>
  - * @version $Id: BasePeer.java,v 1.29 2002/03/06 15:12:25 mpoeschl Exp $
  + * @version $Id: BasePeer.java,v 1.30 2002/03/08 01:19:50 jmcnally Exp $
    */
   public abstract class BasePeer implements java.io.Serializable
   {
  @@ -540,7 +540,7 @@
           String dbName = criteria.getDbName();
   
           // Do the work, assuring the database connection is released.
  -        if (criteria.containsObjectColumn(dbName))
  +        if (criteria.isUseTransaction())
           {
               // For PostgreSQL and LOBs.
               try
  @@ -758,7 +758,7 @@
           ObjectKey id = null;
   
           boolean doTransaction =
  -            criteria.containsObjectColumn(criteria.getDbName());
  +            criteria.isUseTransaction();
   
           try
           {
  @@ -1329,7 +1329,7 @@
           throws TorqueException
       {
           Vector results = null;
  -        if (criteria.containsObjectColumn(criteria.getDbName()))
  +        if (criteria.isUseTransaction())
           {
               DBConnection dbCon = beginTransaction(criteria.getDbName());
               try
  @@ -1714,7 +1714,7 @@
           throws TorqueException
       {
           boolean doTransaction =
  -            updateValues.containsObjectColumn(updateValues.getDbName());
  +            updateValues.isUseTransaction();
           DBConnection db = null;
           try
           {
  @@ -1814,7 +1814,7 @@
           throws TorqueException
       {
           boolean doTransaction =
  -            updateValues.containsObjectColumn(selectCriteria.getDbName());
  +            updateValues.isUseTransaction();
           DBConnection db = null;
           try
           {
  
  
  
  1.16      +29 -1     
jakarta-turbine-torque/src/java/org/apache/torque/util/Criteria.java
  
  Index: Criteria.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/util/Criteria.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- Criteria.java     2 Mar 2002 02:23:55 -0000       1.15
  +++ Criteria.java     8 Mar 2002 01:19:50 -0000       1.16
  @@ -92,7 +92,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Brett McLaughlin</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Eric Dobbs</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Henning P. Schmiedehausen</a>
  - * @version $Id: Criteria.java,v 1.15 2002/03/02 02:23:55 jmcnally Exp $
  + * @version $Id: Criteria.java,v 1.16 2002/03/08 01:19:50 jmcnally Exp $
    */
   public class Criteria extends Hashtable
   {
  @@ -223,6 +223,8 @@
   
       private HashMap aliases = null;
   
  +    private boolean useTransaction = false;     
  +
       /**
        * Log4j category used for logging.
        */
  @@ -399,6 +401,10 @@
        * @return A boolean.
        * @throws TorqueException Any exceptions caught during processing will be
        *         rethrown wrapped into a TorqueException.
  +     * @deprecated not sure why anyone would need to use this outside of its
  +     * use in BasePeer, but it was public, so its now deprecated.
  +     * It was used to decide whether a transaction should be used, this can
  +     * be done with the useTransaction() method.
        */
       public boolean containsObjectColumn(String databaseMapName)
           throws TorqueException
  @@ -430,6 +436,28 @@
               }
           }
           return false;
  +    }
  +
  +    /**
  +     * Will force the sql represented by this criteria to be executed within 
  +     * a transaction.  This is here primarily to support the oid type in
  +     * postgresql.  Though it can be used to require any single sql statement 
  +     * to use a transaction.
  +     */
  +    public void setUseTransaction(boolean v)
  +    {
  +        useTransaction = v;
  +    }
  +
  +    /**
  +     * called by BasePeer to determine whether the sql command specified by
  +     * this criteria must be wrapped in a transaction.
  +     *
  +     * @return a <code>boolean</code> value
  +     */
  +    protected boolean isUseTransaction()
  +    {
  +        return useTransaction;
       }
   
       /**
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to