jmcnally    01/07/13 11:33:24

  Modified:    build    build-turbine-om.xml
               conf/torque build.xml
               conf/torque/templates/om Peer.vm
               src/java/org/apache/turbine/services/db/util Criteria.java
               src/java/org/apache/turbine/torque
                        TorqueObjectModelTask.java
               src/java/org/apache/turbine/torque/engine/database/model
                        Column.java Table.java
  Log:
  fixes problem for postgres with blob style columns.  Tables which use blobs
  will use transactions.  Patch by Jerome Veryleyen modified and extended
  to be included in torque
  
  Revision  Changes    Path
  1.5       +1 -0      jakarta-turbine/build/build-turbine-om.xml
  
  Index: build-turbine-om.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/build/build-turbine-om.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- build-turbine-om.xml      2001/07/02 23:30:24     1.4
  +++ build-turbine-om.xml      2001/07/13 18:32:23     1.5
  @@ -41,6 +41,7 @@
         outputFile="report.turbine.om.generation"
         targetPackage="${targetPackage}"
         xmlFile="${schemaDirectory}/turbine-schema.xml"
  +      targetDatabase="${database}"
       />
   
     </target>
  
  
  
  1.4       +1 -0      jakarta-turbine/conf/torque/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/conf/torque/build.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- build.xml 2001/07/12 20:45:05     1.3
  +++ build.xml 2001/07/13 18:32:37     1.4
  @@ -244,6 +244,7 @@
         outputFile="report.${project}.om.generation"
         targetPackage="${targetPackage}.om"
         xmlFile="${torque.home}/${schemaDirectory}/${project}-schema.xml"
  +      targetDatabase="${database}"
       />
     
     </target>
  
  
  
  1.67      +24 -0     jakarta-turbine/conf/torque/templates/om/Peer.vm
  
  Index: Peer.vm
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/conf/torque/templates/om/Peer.vm,v
  retrieving revision 1.66
  retrieving revision 1.67
  diff -u -r1.66 -r1.67
  --- Peer.vm   2001/07/12 12:30:03     1.66
  +++ Peer.vm   2001/07/13 18:32:44     1.67
  @@ -354,6 +354,11 @@
       public static Vector doSelectVillageRecords( Criteria criteria ) 
           throws Exception
       {
  +    #if ($database == "postgresql" && $table.requiresTransactionInPostgres())
  +         // stuff for postgresql problem.....
  +         criteria.setBlobFlag();
  +    #end 
  + 
       #if ($table.Database.Name != "default")
           criteria.setDbName(mapBuilder.getDatabaseMap().getName());
       #end
  @@ -415,6 +420,11 @@
                                                    DBConnection dbCon ) 
           throws Exception
       {
  +    #if ($database == "postgresql" && $table.requiresTransactionInPostgres())
  +         // stuff for postgresql problem.....
  +         criteria.setBlobFlag();
  +    #end 
  +
           if (criteria.getSelectColumns().size() == 0)
           {
               addSelectColumns ( criteria );
  @@ -1046,7 +1056,14 @@
       protected static Vector doSelectJoin${joinColumnId}(Criteria c)
           throws Exception
       {
  +    #if ($database == "postgresql" && $table.requiresTransactionInPostgres())
  +         // stuff for postgresql problem.....
  +         c.setBlobFlag();
  +    #end 
  +
  +    #if ($table.Database.Name != "default")
            c.setDbName(mapBuilder.getDatabaseMap().getName());
  +    #end
   
           ${table.JavaName}Peer.addSelectColumns(c);
           int offset = numColumns + 1;
  @@ -1194,7 +1211,14 @@
       protected static Vector doSelectJoinAllExcept${excludeString}(Criteria c) 
           throws Exception
       {
  +    #if ($database == "postgresql" && $table.requiresTransactionInPostgres())
  +         // stuff for postgresql problem.....
  +         c.setBlobFlag();
  +    #end 
  + 
  +    #if ($table.Database.Name != "default")
            c.setDbName(mapBuilder.getDatabaseMap().getName());
  +    #end
   
           addSelectColumns(c);
           int offset2 = numColumns + 1;
  
  
  
  1.3       +24 -1     
jakarta-turbine/src/java/org/apache/turbine/services/db/util/Criteria.java
  
  Index: Criteria.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/db/util/Criteria.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Criteria.java     2001/07/10 02:41:03     1.2
  +++ Criteria.java     2001/07/13 18:32:52     1.3
  @@ -96,7 +96,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.2 2001/07/10 02:41:03 jon Exp $
  + * @version $Id: Criteria.java,v 1.3 2001/07/13 18:32:52 jmcnally Exp $
    */
   public class Criteria extends Hashtable
   {
  @@ -210,6 +210,10 @@
        */
       private int offset = 0;
   
  +    // flag to note that the criteria involves a blob.
  +    private boolean blobFlag = false;
  +
  +
       private HashMap aliases = null;
   
       /**
  @@ -384,6 +388,13 @@
       public boolean containsObjectColumn(String databaseMapName)
           throws Exception
       {
  +        // Peer or application may have noted the existence of a blob
  +        // so we can save the lookup.
  +        if ( blobFlag )
  +        {
  +            return true;
  +        }
  +
           DatabaseMap map = TurbineDB.getDatabaseMap(databaseMapName);
           StringStackBuffer tables = new StringStackBuffer();
           for (Enumeration e = super.elements(); e.hasMoreElements(); )
  @@ -3118,6 +3129,18 @@
       {
           or(column, (Object)values, Criteria.NOT_IN);
           return this;
  +    }
  +
  +    
  +    /**
  +     * Peers can set this flag to notify BasePeer that the table(s) involved
  +     * in the Criteria contain Blobs, so that the operation can be placed
  +     * in a transaction if the db requires it.  
  +     * This is primarily to support Postgresql.
  +     */
  +    public void setBlobFlag() 
  +    {
  +        blobFlag = true;
       }
   
       /**
  
  
  
  1.6       +34 -1     
jakarta-turbine/src/java/org/apache/turbine/torque/TorqueObjectModelTask.java
  
  Index: TorqueObjectModelTask.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/torque/TorqueObjectModelTask.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TorqueObjectModelTask.java        2001/03/25 23:08:05     1.5
  +++ TorqueObjectModelTask.java        2001/07/13 18:33:03     1.6
  @@ -68,7 +68,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
    * @author <a href="mailto:[EMAIL PROTECTED]>John McNally</a>
  - * @version $Id: TorqueObjectModelTask.java,v 1.5 2001/03/25 23:08:05 jvanzyl Exp $
  + * @version $Id: TorqueObjectModelTask.java,v 1.6 2001/07/13 18:33:03 jmcnally Exp $
    */
   
   public class TorqueObjectModelTask extends TexenTask
  @@ -88,6 +88,14 @@
        * files in.
        */
       private String targetPackage;
  +
  +    /**
  +     * The target database(s) we are generating SQL
  +     * for. Right now we can only deal with a single
  +     * target, but we will support multiple targets
  +     * soon.
  +     */
  +    private String targetDatabase;
       
       /**
        * Get the current xml file.
  @@ -130,6 +138,26 @@
           targetPackage = v;
       }
   
  +    /**
  +     * Get the current target database.
  +     *
  +     * @return String target database(s)
  +     */
  +    public String getTargetDatabase ()
  +    {
  +        return targetDatabase;
  +    }
  +
  +    /**
  +     * Set the current target database.
  +     *
  +     * @param String target database(s)
  +     */
  +    public void setTargetDatabase (String v)
  +    {
  +        targetDatabase = v;
  +    }
  +
       public Context initControlContext()
       {
           /*
  @@ -154,6 +182,11 @@
            * option.
            */
           context.put("appData", app);
  +
  +        /*
  +         * Place the target database in the context.
  +         */
  +        context.put("targetDatabase", targetDatabase);
           
           return context;
       }
  
  
  
  1.8       +15 -2     
jakarta-turbine/src/java/org/apache/turbine/torque/engine/database/model/Column.java
  
  Index: Column.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/torque/engine/database/model/Column.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Column.java       2001/06/21 00:40:40     1.7
  +++ Column.java       2001/07/13 18:33:12     1.8
  @@ -70,7 +70,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jon S. Stevens</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Daniel Rall</a>
  - * @version $Id: Column.java,v 1.7 2001/06/21 00:40:40 dlr Exp $
  + * @version $Id: Column.java,v 1.8 2001/07/13 18:33:12 jmcnally Exp $
    */
   public class Column
   {
  @@ -95,6 +95,7 @@
       private boolean isInheritance;
       private boolean isEnumeratedClasses;
       private List inheritanceList;
  +    private boolean needsTransactionInPostgres;
   
       // class name to do input validation on this column
       private String inputValidator = null;
  @@ -150,7 +151,7 @@
   
           size = attrib.getValue("size");
           
  -        torqueType = attrib.getValue("type");
  +        setType(attrib.getValue("type"));
   
           inheritanceType = attrib.getValue("inheritance");
           isInheritance = 
  @@ -353,6 +354,14 @@
       }
   
       /**
  +     * Return true if the column requires a transaction in Postgres
  +     */
  +    public boolean requiresTransactionInPostgres()
  +    {
  +        return needsTransactionInPostgres;
  +    }
  +
  +    /**
        * Utility method to determine if this column
        * is a foreign key.
        */
  @@ -456,6 +465,10 @@
       public void setType(String torqueType)
       {
           this.torqueType = torqueType;
  +        if ( torqueType.equals("VARBINARY") || torqueType.equals("BLOB") ) 
  +        {
  +            needsTransactionInPostgres = true;   
  +        }
       }
   
       /**
  
  
  
  1.20      +11 -1     
jakarta-turbine/src/java/org/apache/turbine/torque/engine/database/model/Table.java
  
  Index: Table.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/torque/engine/database/model/Table.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- Table.java        2001/06/19 20:01:49     1.19
  +++ Table.java        2001/07/13 18:33:15     1.20
  @@ -71,7 +71,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]>Martin Poeschl</a>
    * @author <a href="mailto:[EMAIL PROTECTED]>John McNally</a>
    * @author <a href="mailto:[EMAIL PROTECTED]>Daniel Rall</a>
  - * @version $Id: Table.java,v 1.19 2001/06/19 20:01:49 mpoeschl Exp $
  + * @version $Id: Table.java,v 1.20 2001/07/13 18:33:15 jmcnally Exp $
    */
   public class Table
   {
  @@ -103,6 +103,7 @@
       private String basePeer;
       private Hashtable columnsByName;
       private Hashtable columnsByJavaName;
  +    private boolean needsTransactionInPostgres;
   
       /**
        * Default Constructor
  @@ -240,6 +241,7 @@
           columnsByName.put(col.getName(), col);
           columnsByJavaName.put(col.getJavaName(), col);
           col.setPosition(columnList.size());
  +        needsTransactionInPostgres |= col.requiresTransactionInPostgres();
       }
   
       /**
  @@ -345,6 +347,14 @@
           {
               foreignTableNames.add(fk.getForeignTableName());
           }
  +    }
  +
  +    /**
  +     * Return true if the column requires a transaction in Postgres
  +     */
  +    public boolean requiresTransactionInPostgres()
  +    {
  +        return needsTransactionInPostgres;
       }
   
       /**
  
  
  

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

Reply via email to