You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by tf...@apache.org on 2005/11/27 13:15:31 UTC

svn commit: r349221 - in /db/torque: common/trunk/ runtime/trunk/src/java/org/apache/torque/adapter/ runtime/trunk/xdocs/ templates/trunk/src/templates/sql/base/derby/

Author: tfischer
Date: Sun Nov 27 04:15:16 2005
New Revision: 349221

URL: http://svn.apache.org/viewcvs?rev=349221&view=rev
Log:
Extended support for derby.
- IdMethod native is now supported
- Added mappings for Torque types LONGVARCHAR, BINARY and VARBINARY
- Implemented the methods getMaxColumnNameLength(), hasScale() and hasSize() in PlatformDerbyImpl
- Foreign keys are now declared outside the CREATE TABLE statement, allowing to create foreign references independent of the order of tables in the schema.xml
- The SQL for the creation of Indices is now generated correctly (a CRLF was missing at the end)
Thanks to Johnny Macchione for the patches. 

Added Johnny Macchione as a contributor
Updated information about derby in list of supported databases

Modified:
    db/torque/common/trunk/project.xml
    db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBDerby.java
    db/torque/runtime/trunk/xdocs/changes.xml
    db/torque/runtime/trunk/xdocs/index.xml
    db/torque/templates/trunk/src/templates/sql/base/derby/foreignkey.vm
    db/torque/templates/trunk/src/templates/sql/base/derby/table.vm
    db/torque/templates/trunk/src/templates/sql/base/derby/tablefk.vm

Modified: db/torque/common/trunk/project.xml
URL: http://svn.apache.org/viewcvs/db/torque/common/trunk/project.xml?rev=349221&r1=349220&r2=349221&view=diff
==============================================================================
--- db/torque/common/trunk/project.xml (original)
+++ db/torque/common/trunk/project.xml Sun Nov 27 04:15:16 2005
@@ -281,6 +281,10 @@
       <email>thierry.lach@bbdodetroit.com</email>
     </contributor>
     <contributor>
+      <name>Johnny Macchione</name>
+      <email>johnnymac@tiscali.be</email>
+    </contributor>
+    <contributor>
       <name>Markus M. May</name>
       <email>mmay@javafreedom.org</email>
     </contributor>

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBDerby.java
URL: http://svn.apache.org/viewcvs/db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBDerby.java?rev=349221&r1=349220&r2=349221&view=diff
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBDerby.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBDerby.java Sun Nov 27 04:15:16 2005
@@ -67,15 +67,19 @@
      */
     public String getIDMethodType()
     {
-        return NO_ID_METHOD; // @todo IDENTITY;
+        return AUTO_INCREMENT;
     }
 
     /**
+     * Returns the SQL to get the database key of the last row
+     * inserted, which in this case is 
+     * <code>VALUES IDENTITY_VAL_LOCAL()</code>.
+     * 
      * @see org.apache.torque.adapter.DB#getIDMethodSQL(Object obj)
      */
     public String getIDMethodSQL(Object obj)
     {
-        return ""; // @todo VALUES IDENTITY_VAL_LOCAL()";
+        return "VALUES IDENTITY_VAL_LOCAL()";
     }
 
     /**

Modified: db/torque/runtime/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewcvs/db/torque/runtime/trunk/xdocs/changes.xml?rev=349221&r1=349220&r2=349221&view=diff
==============================================================================
--- db/torque/runtime/trunk/xdocs/changes.xml (original)
+++ db/torque/runtime/trunk/xdocs/changes.xml Sun Nov 27 04:15:16 2005
@@ -26,6 +26,32 @@
   <body>
 
   <release version="3.2-rc4-dev" date="in SVN">
+    <action type="add" dev="tfischer">
+      Extended support for derby.
+      <ul>
+        <li>
+          IdMethod native is now supported
+        </li>
+        <li>
+          Added mappings for Torque types 
+          LONGVARCHAR, BINARY and VARBINARY
+        </li>
+        <li>
+          Implemented the fuctions getMaxColumnNameLength(), 
+          hasScale() and hasSize() in PlatformDerbyImpl
+        </li>
+        <li>
+          Foreign keys are now declared outside the CREATE TABLE statement,
+          allowing to create foreign references independent of the order of
+          tables in the schema.xml
+        </li>
+        <li>
+          The SQL for the creation of Indices is now generated correctly 
+          (a CRLF was missing at the end)
+        </li>
+      </ul>
+      Thanks to Johnny Macchione for the patches. 
+    </action>
     <action type="fix" dev="tfischer">
       Fixed foreign key support in mysql to allow the referenced table to
       be declared before the referencing table.

Modified: db/torque/runtime/trunk/xdocs/index.xml
URL: http://svn.apache.org/viewcvs/db/torque/runtime/trunk/xdocs/index.xml?rev=349221&r1=349220&r2=349221&view=diff
==============================================================================
--- db/torque/runtime/trunk/xdocs/index.xml (original)
+++ db/torque/runtime/trunk/xdocs/index.xml Sun Nov 27 04:15:16 2005
@@ -80,7 +80,7 @@
         <tr>
           <td>Derby</td>
           <td>org.apache.derby.jdbc.EmbeddedDriver</td>
-          <td>Only the embedded driver works. idMethod=&quot;native&quot; does not work.</td>
+          <td>Only the embedded driver works.</td>
           <td><a href="mailto:fischer@seitenbau.de">Thomas Fischer</a></td>
         </tr>
         <tr>

Modified: db/torque/templates/trunk/src/templates/sql/base/derby/foreignkey.vm
URL: http://svn.apache.org/viewcvs/db/torque/templates/trunk/src/templates/sql/base/derby/foreignkey.vm?rev=349221&r1=349220&r2=349221&view=diff
==============================================================================
--- db/torque/templates/trunk/src/templates/sql/base/derby/foreignkey.vm (original)
+++ db/torque/templates/trunk/src/templates/sql/base/derby/foreignkey.vm Sun Nov 27 04:15:16 2005
@@ -12,12 +12,16 @@
 ## See the License for the specific language governing permissions and
 ## limitations under the License.
 #foreach ($fk in $table.ForeignKeys)
-    FOREIGN KEY ($fk.LocalColumnNames) REFERENCES $fk.ForeignTableName ($fk.ForeignColumnNames)
+ALTER TABLE $table.Name
+    ADD CONSTRAINT $fk.Name 
+    FOREIGN KEY ($fk.LocalColumnNames)
+    REFERENCES $fk.ForeignTableName ($fk.ForeignColumnNames)
   #if ($fk.hasOnUpdate())
     ON UPDATE $fk.OnUpdate
   #end
   #if ($fk.hasOnDelete())
     ON DELETE $fk.OnDelete
   #end
-,
-#end
+;
+
+#end
\ No newline at end of file

Modified: db/torque/templates/trunk/src/templates/sql/base/derby/table.vm
URL: http://svn.apache.org/viewcvs/db/torque/templates/trunk/src/templates/sql/base/derby/table.vm?rev=349221&r1=349220&r2=349221&view=diff
==============================================================================
--- db/torque/templates/trunk/src/templates/sql/base/derby/table.vm (original)
+++ db/torque/templates/trunk/src/templates/sql/base/derby/table.vm Sun Nov 27 04:15:16 2005
@@ -19,13 +19,11 @@
 (
 #set ( $cols = $generator.parse("$basepath/columns.vm", "", "table", $tbl) )
 #set ( $pk = $generator.parse("$basepath/primarykey.vm", "", "table", $tbl) )
-#set ( $fk = $generator.parse("$basepath/foreignkey.vm", "", "table", $tbl) )
 #set ( $unique = $generator.parse("$basepath/unique.vm", "", "table", $tbl) )
 #set ( $index = $generator.parse("$basepath/index.vm", "", "table", $tbl) )
-#if($strings.allEmpty([$pk,$fk,$unique,$index]))$strings.chop($cols,2)#else$cols#end
-#if($strings.allEmpty([$fk,$unique,$index]) && $pk.length() > 0)$strings.chop($pk,2)#else$pk#end
-#if($strings.allEmpty([$unique,$index]) && $fk.length() > 0)$strings.chop($fk,2)#else$fk#end
+#if($strings.allEmpty([$pk,$unique]))$strings.chop($cols,2)#else$cols#end
+#if($strings.allEmpty([$unique]) && $pk.length() > 0)$strings.chop($pk,2)#else$pk#end
 #if($unique.length() > 0)$strings.chop($unique,2)#else$unique#end
 );
 
-#if($index.length() > 0)$strings.chop($index,1)#end
+#if($index.length() > 0)$index#end

Modified: db/torque/templates/trunk/src/templates/sql/base/derby/tablefk.vm
URL: http://svn.apache.org/viewcvs/db/torque/templates/trunk/src/templates/sql/base/derby/tablefk.vm?rev=349221&r1=349220&r2=349221&view=diff
==============================================================================
--- db/torque/templates/trunk/src/templates/sql/base/derby/tablefk.vm (original)
+++ db/torque/templates/trunk/src/templates/sql/base/derby/tablefk.vm Sun Nov 27 04:15:16 2005
@@ -11,3 +11,5 @@
 ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 ## See the License for the specific language governing permissions and
 ## limitations under the License.
+#set ( $fk = $generator.parse("$basepath/foreignkey.vm", "", "table", $tbl) )
+#if ($fk.length()>0)$fk#end
\ No newline at end of file



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