db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gmon...@apache.org
Subject svn commit: r482880 - in /db/torque: generator/trunk/src/java/org/apache/torque/engine/database/model/SizedForBitDataDomain.java generator/trunk/src/java/org/apache/torque/engine/platform/PlatformDerbyImpl.java site/trunk/xdocs/changes.xml
Date Wed, 06 Dec 2006 03:55:27 GMT
Author: gmonroe
Date: Tue Dec  5 19:55:24 2006
New Revision: 482880

URL: http://svn.apache.org/viewvc?view=rev&rev=482880
Log:
Added a new Generator model Domain subclass called SizedForBitDataDomain
to support the DB2/Derby CHAR/VARCHAR (size) AS BIT DATA format.

Improved Derby generator platform implimentation to support correctly
sized BINARY and VARBINARY using the SizedAsBitDataDomain.  Also fixed 
problems with the BIT and TINYINT mappings.

Added:
    db/torque/generator/trunk/src/java/org/apache/torque/engine/database/model/SizedForBitDataDomain.java
Modified:
    db/torque/generator/trunk/src/java/org/apache/torque/engine/platform/PlatformDerbyImpl.java
    db/torque/site/trunk/xdocs/changes.xml

Added: db/torque/generator/trunk/src/java/org/apache/torque/engine/database/model/SizedForBitDataDomain.java
URL: http://svn.apache.org/viewvc/db/torque/generator/trunk/src/java/org/apache/torque/engine/database/model/SizedForBitDataDomain.java?view=auto&rev=482880
==============================================================================
--- db/torque/generator/trunk/src/java/org/apache/torque/engine/database/model/SizedForBitDataDomain.java
(added)
+++ db/torque/generator/trunk/src/java/org/apache/torque/engine/database/model/SizedForBitDataDomain.java
Tue Dec  5 19:55:24 2006
@@ -0,0 +1,135 @@
+package org.apache.torque.engine.database.model;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, 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.
+ */
+
+/**
+ * <p>
+ * Supports the Derby / DB2 / SQL92 standard for defining Binary data fields 
+ * with either CHAR(#) FOR BIT DATA or VARCHAR(#) FOR BIT DATA. This can be 
+ * used in Platform implimentors initialize() methods, by using lines like:
+ * </p>
+ * <code>
+ * setSchemaDomainMapping(new SizedForBitDataDomain(
+ *                          SchemaType.BINARY, "CHAR", "1"));
+ * setSchemaDomainMapping(new SizedForBitDataDomain(
+ *                          SchemaType.VARBINARY, "VARCHAR"));
+ * </code>
+ * <p>
+ * This will cause the Column.getSqlString() method to produce items similar to:
+ * </p>
+ * <code>
+ * CHAR(#) FOR BIT DATA
+ * VARCHAR(#)FOR BIT DATA
+ * </code>
+ * <p>
+ * Where: # is the size= schema attribute or a default size specified in the
+ * constructor.
+ * </p>
+ * <p>
+ * Note that this is dependent on the platform implimentation correctly defining
+ * BINARY and VARBINARY as having a size attribute in the "hasSize()" method.
+ * </p>
+ *
+ * @see org.apache.torque.engine.platform.Platform
+ * @see org.apache.torque.engine.database.model.Column#getSqlString()
+ * @author <a href="Monroe@DukeCE.com">Greg Monroe</a>
+ */
+public class SizedForBitDataDomain extends Domain
+{
+
+    /**
+     * @see org.apache.torque.engine.database.model.Domain#Domain()
+     */
+    public SizedForBitDataDomain()
+    {
+        super();
+    }
+
+    /**
+     * @see org.apache.torque.engine.database.model.Domain#Domain(String)
+     */
+    public SizedForBitDataDomain(String name)
+    {
+        super(name);
+    }
+
+    /**
+     * @see org.apache.torque.engine.database.model.Domain#Domain(SchemaType)
+     */
+    public SizedForBitDataDomain(SchemaType type)
+    {
+        super(type);
+    }
+
+    /**
+     * @see org.apache.torque.engine.database.model.Domain#
+     *              Domain(SchemaType, String)
+     */
+    public SizedForBitDataDomain(SchemaType type, String sqlType)
+    {
+        super(type, sqlType);
+    }
+
+    /**
+     * @see org.apache.torque.engine.database.model.Domain#
+     *              Domain(SchemaType, String, String, String)
+     */
+    public SizedForBitDataDomain(SchemaType type, String sqlType, String size,
+            String scale)
+    {
+        super(type, sqlType, size, scale);
+    }
+
+    /**
+     * @see org.apache.torque.engine.database.model.Domain#
+     *              Domain(SchemaType, String, String)
+     */
+    public SizedForBitDataDomain(SchemaType type, String sqlType, String size)
+    {
+        super(type, sqlType, size);
+    }
+
+    /**
+     * @see org.apache.torque.engine.database.model.Domain#
+     *              Domain(Domain)
+     */
+    public SizedForBitDataDomain(Domain domain)
+    {
+        super(domain);
+    }
+
+    /**
+     * Returns the size postfix for the base SQL Column type.
+     *
+     * @return "(size) FOR BIT DATA" or just " FOR BIT DATA" if size
+     * is null.
+     * @see org.apache.torque.engine.database.model.Domain#getSize()
+     */
+    public String printSize()
+    {
+        String result = "";
+        if ( getSize() != null )
+        {
+            result =  "(" + getSize() + ")";
+        }
+        result = result + " FOR BIT DATA";
+        return result;
+    }
+}

Modified: db/torque/generator/trunk/src/java/org/apache/torque/engine/platform/PlatformDerbyImpl.java
URL: http://svn.apache.org/viewvc/db/torque/generator/trunk/src/java/org/apache/torque/engine/platform/PlatformDerbyImpl.java?view=diff&rev=482880&r1=482879&r2=482880
==============================================================================
--- db/torque/generator/trunk/src/java/org/apache/torque/engine/platform/PlatformDerbyImpl.java
(original)
+++ db/torque/generator/trunk/src/java/org/apache/torque/engine/platform/PlatformDerbyImpl.java
Tue Dec  5 19:55:24 2006
@@ -21,11 +21,13 @@
 
 import org.apache.torque.engine.database.model.Domain;
 import org.apache.torque.engine.database.model.SchemaType;
+import org.apache.torque.engine.database.model.SizedForBitDataDomain;
 
 /**
  * Derby Platform implementation.
  *
  * @author <a href="mailto:johnnymac@tiscali.be">Johnny Macchione</a>
+ * @author <a href="Monroe@DukeCE.com">Greg Monroe</a>
  * @version $Id$
  */
 public class PlatformDerbyImpl extends PlatformDefaultImpl
@@ -45,21 +47,21 @@
      */
     private void initialize()
     {
-        setSchemaDomainMapping(new Domain(SchemaType.LONGVARCHAR, "LONG VARCHAR"));
+        setSchemaDomainMapping(
+                    new Domain(SchemaType.LONGVARCHAR, "LONG VARCHAR"));
 
-        // PENDING: Support CHAR(n) FOR BIT DATA: n [1;254]
-        // The size is always appended to the type in the templates => CHAR FOR BIT DATA()!
-        //setSchemaDomainMapping(new Domain(SchemaType.BINARY, "CHAR(2048) FOR BIT DATA"));
-
-        // PENDING: Support VARCHAR(n) FOR BIT DATA: n [1;32672]
-        // The size is always appended to the type in the templates => VARCHAR FOR BIT
DATA()!
-        //setSchemaDomainMapping(new Domain(SchemaType.VARBINARY, "VARCHAR(2048) FOR BIT
DATA"));
-
-        // Mapped to VARBINARY, because LONG VARCHAR FOR BIT DATA doesn't require a size;
-        // turbine-schema.xml declares TURBINE_USER.OBJECT_DATA as VARBINARY without size
-        setSchemaDomainMapping(new Domain(SchemaType.VARBINARY, "LONG VARCHAR FOR BIT DATA"));
-        setSchemaDomainMapping(new Domain(SchemaType.LONGVARBINARY, "LONG VARCHAR FOR BIT
DATA"));
-        setSchemaDomainMapping(new Domain(SchemaType.LONGVARCHAR, "LONG VARCHAR"));
+        setSchemaDomainMapping( new SizedForBitDataDomain(
+                                    SchemaType.VARBINARY, "VARCHAR", "32672"));
+        setSchemaDomainMapping(
+                new SizedForBitDataDomain(SchemaType.BINARY, "CHAR", "1"));
+        setSchemaDomainMapping( new Domain(SchemaType.LONGVARBINARY,
+                                                "LONG VARCHAR FOR BIT DATA"));
+        setSchemaDomainMapping(
+                new Domain(SchemaType.LONGVARCHAR, "LONG VARCHAR"));
+        setSchemaDomainMapping(
+                new Domain(SchemaType.BIT,"CHAR(1)"));
+        setSchemaDomainMapping(
+                new Domain(SchemaType.TINYINT, "SMALLINT"));
     }
 
     /**
@@ -101,7 +103,7 @@
     {
         return "NUMERIC".equals(sqlType) || "DECIMAL".equals(sqlType)
             || "VARCHAR".equals(sqlType) || "CHAR".equals(sqlType)
-            || "BINARY".equals(sqlType)
+            || "BINARY".equals(sqlType) || "VARBINARY".equals(sqlType)
             || "BLOB".equals(sqlType) || "CLOB".equals(sqlType);
     }
 }

Modified: db/torque/site/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/db/torque/site/trunk/xdocs/changes.xml?view=diff&rev=482880&r1=482879&r2=482880
==============================================================================
--- db/torque/site/trunk/xdocs/changes.xml (original)
+++ db/torque/site/trunk/xdocs/changes.xml Tue Dec  5 19:55:24 2006
@@ -33,8 +33,17 @@
 
   <release version="3.3" date="in SVN">
     <action type="fix" dev="gmonroe">
+      Improved Derby generator platform implimentation to support correctly
+      sized BINARY and VARBINARY using the SizedAsBitDataDomain.  Also fixed 
+      problems with the BIT and TINYINT mappings.
+    </action>
+    <action type="add" dev="gmonroe">
+      Added a new Generator model Domain subclass called SizedForBitDataDomain
+      to support the DB2/Derby CHAR/VARCHAR (size) AS BIT DATA format.
+    </action>
+    <action type="fix" dev="gmonroe">
       Fixed template package references that caused bad code to be generated
-      if non-default packages where used.        
+      if non-default packages were used.        
     </action>
   </release>
   <release version="3.3-RC1" date="2006-11-23">



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


Mime
View raw message