You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jm...@apache.org on 2001/05/03 22:59:47 UTC

cvs commit: jakarta-turbine/conf/torque/templates/sql/id-table idtable.sybase

jmcnally    01/05/03 13:59:47

  Modified:    src/java/org/apache/turbine/om DateKey.java NumberKey.java
                        StringKey.java
               src/java/org/apache/turbine/om/peer BasePeer.java
               conf/torque/templates/sql/base/sybase columns.vm db.props
                        table.vm
               conf/torque/templates/sql/id-table idtable.sybase
  Log:
  patches by Jeffrey D. Brekke
  
  * BasePeer.java.diff
  Just removed the dbname parameter from the executeQuery() method since a
  DBConnection was also being passed and the name string was not being used.
  
  * key.diff
  In Object.vm the copy() method generated code that attempted to set any
  primary or foreign key object to null.  Since these key objects hold the
  value, the null was attempting to be set in the key object and the
  setValue() methods didn't check for null's.  So DateKey.java,
  NumberKey.java, and StringKey.java setValue() methods now check if the param
  passed is null and set the internal member accordingly.
  
  * Peer.vm.diff
  Added a method getMapBuilder() to return the internal mapbuilder member.
  Since the getMapBuilder() in BasePeer returned the default mapbuilder, the
  torque gen'd ones weren't being used in the Object.vm gen'd save() method.
  
  Also added retrieveByPK() methods that accepted a DBConnection.  Reworked
  the existing retireveByPK() to just use the default connection.
  
  * sybase.diff
  In sybase/columns.vm, suppressDefaults and removeNotNullWithAutoincrement
  were'nt adjusting the generated sql properly: fixed.  Updated some default
  values in sybase/db.props and added some documentation to the settings.
  Updated table.vm and tablefk.vm to put the foreign key definitions at the
  bottom of the gen'd sql.  Uppercased column names in the idtable.sybase file
  to match the schema.
  
  * security-sql.diff
  Changed the # comments back to /* */ since this file is for use with the sql
  ant task and the # was screwing up the execution.  I remember some
  discussion on this a while back, but don't remember if there was an outcome.
  But on sybase and mysql ( don't remember which ver ), when ant executes the
  .sql with # comments, it barfs.
  
  Revision  Changes    Path
  1.6       +4 -1      jakarta-turbine/src/java/org/apache/turbine/om/DateKey.java
  
  Index: DateKey.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/om/DateKey.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DateKey.java	2001/03/27 18:10:50	1.5
  +++ DateKey.java	2001/05/03 20:59:33	1.6
  @@ -111,7 +111,10 @@
        */
       public void setValue(DateKey key)
       {
  -        this.key = key.getValue();
  +        if (key != null)
  +            this.key = key.getValue();
  +        else
  +            this.key = null;
       }
   
       /**
  
  
  
  1.5       +4 -1      jakarta-turbine/src/java/org/apache/turbine/om/NumberKey.java
  
  Index: NumberKey.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/om/NumberKey.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- NumberKey.java	2001/03/27 06:48:29	1.4
  +++ NumberKey.java	2001/05/03 20:59:33	1.5
  @@ -119,7 +119,10 @@
        */
       public void setValue(NumberKey key)
       {
  -        this.key = key.getValue();
  +        if (key != null)
  +            this.key = key.getValue();
  +        else
  +            this.key = null;
       }
   
       /**
  
  
  
  1.6       +4 -1      jakarta-turbine/src/java/org/apache/turbine/om/StringKey.java
  
  Index: StringKey.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/om/StringKey.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- StringKey.java	2001/03/27 18:10:50	1.5
  +++ StringKey.java	2001/05/03 20:59:35	1.6
  @@ -102,7 +102,10 @@
        */
       public void setValue(StringKey key)
       {
  -        this.key = key.getValue();
  +        if (key != null)
  +            this.key = key.getValue();
  +        else
  +            this.key = null;
       }
   
       /**
  
  
  
  1.58      +2 -4      jakarta-turbine/src/java/org/apache/turbine/om/peer/BasePeer.java
  
  Index: BasePeer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/om/peer/BasePeer.java,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- BasePeer.java	2001/04/30 22:10:10	1.57
  +++ BasePeer.java	2001/05/03 20:59:39	1.58
  @@ -88,7 +88,7 @@
    * @author <a href="mailto:frank.kim@clearink.com">Frank Y. Kim</a>
    * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
    * @author <a href="mailto:bmclaugh@algx.net">Brett McLaughlin</a>
  - * @version $Id: BasePeer.java,v 1.57 2001/04/30 22:10:10 dlr Exp $
  + * @version $Id: BasePeer.java,v 1.58 2001/05/03 20:59:39 jmcnally Exp $
    */
   public abstract class BasePeer
   {
  @@ -1688,7 +1688,7 @@
               // Get a connection to the db.
               db = TurbineDB.getConnection( dbName );
   
  -            rowCount = executeStatement( stmt, dbName, db );
  +            rowCount = executeStatement( stmt, db );
           }
           finally
           {
  @@ -1704,13 +1704,11 @@
        * statements.  Use executeQuery() for selects.
        *
        * @param stmt A String with the sql statement to execute.
  -     * @param dbName Name of database to connect to.
        * @param dbCon A DBConnection.
        * @return The number of rows affected.
        * @exception Exception, a generic exception.
        */
       public static int executeStatement(String stmt,
  -                                       String dbName,
                                          DBConnection dbCon)
           throws Exception
       {
  
  
  
  1.5       +10 -2     jakarta-turbine/conf/torque/templates/sql/base/sybase/columns.vm
  
  Index: columns.vm
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/conf/torque/templates/sql/base/sybase/columns.vm,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- columns.vm	2001/02/27 16:37:43	1.4
  +++ columns.vm	2001/05/03 20:59:41	1.5
  @@ -1,8 +1,16 @@
   #foreach ($col in $table.Columns)
       #set ( $type = $dbprops.get($col.Type) )
       #set ( $size = $col.printSize() )
  -    #set ( $default = $col.DefaultSetting )
  -    #set ( $nullString = $strings.select($col.isNotNull(), $dbprops.get("NOTNULL"),"NULL") )
  +    #if ( $dbprops.get("supressDefaults") == "true" )
  +        #set ( $default = "" )
  +    #else
  +        #set ( $default = $col.DefaultSetting )
  +    #end
  +    #if ( ($dbprops.get("removeNotNullWithAutoIncrement") == "true") && $col.isAutoIncrement() && $col.isNotNull() )
  +       #set ( $nullString = "" )
  +    #else
  +       #set ( $nullString = $strings.select($col.isNotNull(), $dbprops.get("NOTNULL"),"NULL") )
  +    #end
       #set ( $autoIncrement = $strings.select($col.isAutoIncrement(), $dbprops.get("AUTOINCREMENT"),"") )
       #set ( $entry = "$col.Name $type $size $default $nullString $autoIncrement," )
       $strings.sub($strings.collapseSpaces($entry)," ,",",")
  
  
  
  1.3       +32 -3     jakarta-turbine/conf/torque/templates/sql/base/sybase/db.props
  
  Index: db.props
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/conf/torque/templates/sql/base/sybase/db.props,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- db.props	2001/01/24 21:32:11	1.2
  +++ db.props	2001/05/03 20:59:42	1.3
  @@ -11,7 +11,7 @@
   DOUBLE =
   NUMERIC = NUMERIC
   DECIMAL =
  -CHAR = VARCHAR
  +CHAR = CHAR
   VARCHAR = VARCHAR
   LONGVARCHAR = TEXT
   DATE = DATETIME
  @@ -20,7 +20,7 @@
   BINARY = BINARY
   VARBINARY = IMAGE
   LONGVARBINARY = IMAGE
  -NULL =
  +NULL = NULL
   OTHER =
   JAVA_OBJECT =
   DISTINCT =
  @@ -30,9 +30,38 @@
   CLOB =
   REF =
   
  +#
  +# This is the autoincrement value if using native methods for
  +# incrementing keys.  Most likely IDENTITIY wrt Sybase ASE.
  +# Leaving the value blank should be used when Turbine's IDBroker
  +# is used to autoincrement keys.
  +#
  +# Default: [blank]
  +#
   AUTOINCREMENT =
  -NOTNULL = NOT NULL
   
  +#
  +# If true, the NOT NULL values will not be printed in generated 
  +# SQL files if the column is set to autoincrement.  Should be true
  +# when the internal IDENTITY attribute ( above ) is used in a column
  +# for autoincrementing keys.
  +#
  +# Default: false
  +#
   removeNotNullWithAutoIncrement = false
   
  +#
  +# If true, defaults are not included in generated SQL.
  +#
  +# Default: false
  +#
   suppressDefaults = false
  +
  +#
  +# The string to place in the generated SQL for columns which cannot
  +# be NULL.
  +#
  +# Default: NOT NULL
  +#
  +NOTNULL = NOT NULL
  +
  
  
  
  1.5       +0 -3      jakarta-turbine/conf/torque/templates/sql/base/sybase/table.vm
  
  Index: table.vm
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/conf/torque/templates/sql/base/sybase/table.vm,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- table.vm	2001/02/27 16:37:43	1.4
  +++ table.vm	2001/05/03 20:59:43	1.5
  @@ -15,8 +15,5 @@
   
   );
   
  -#set ( $fk = $generator.parse("$basepath/foreignkey.vm", "", "table", $tbl) )
  -#if($fk.length() >0)$fk#end
  -
   #set ( $index = $generator.parse("$basepath/index.vm", "", "table", $tbl) )
   #if($index.length() > 0)$index#end
  
  
  
  1.3       +2 -2      jakarta-turbine/conf/torque/templates/sql/id-table/idtable.sybase
  
  Index: idtable.sybase
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/conf/torque/templates/sql/id-table/idtable.sybase,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- idtable.sybase	2001/01/24 21:32:12	1.2
  +++ idtable.sybase	2001/05/03 20:59:46	1.3
  @@ -1,5 +1,5 @@
  -delete from ID_TABLE where id_table_id >= $initialID;
  +delete from ID_TABLE where ID_TABLE_ID >= $initialID;
   #foreach ($tbl in $tables)
  -insert into ID_TABLE (id_table_id, table_name, next_id, quantity) VALUES ($initialID, '$tbl.Name', 100, 10);
  +insert into ID_TABLE (ID_TABLE_ID, TABLE_NAME, NEXT_ID, QUANTITY) VALUES ($initialID, '$tbl.Name', 100, 10);
   #set ( $initialID = $initialID + 1 )
   #end
  
  
  

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


Re: cvs commit: jakarta-turbine/conf/torque/templates/sql/id-table idtable.sybase

Posted by Jon Stevens <jo...@latchkey.com>.
on 5/3/01 1:59 PM, "jmcnally@apache.org" <jm...@apache.org> wrote:

> * security-sql.diff
> Changed the # comments back to /* */ since this file is for use with the sql
> ant task and the # was screwing up the execution.  I remember some
> discussion on this a while back, but don't remember if there was an outcome.
> But on sybase and mysql ( don't remember which ver ), when ant executes the
> .sql with # comments, it barfs.
> 

Thank you. Could you also make sure that there are no ' " characters in the
comments? That is what mysql is puking on.

-jon

-- 
If you come from a Perl or PHP background, JSP is a way to take
your pain to new levels. --Anonymous
<http://jakarta.apache.org/velocity/ymtd/ymtd.html>


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