db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1167504 - in /db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates: platform/ transformer/om/ transformer/sql/
Date Sat, 10 Sep 2011 12:33:47 GMT
Author: tfischer
Date: Sat Sep 10 12:33:46 2011
New Revision: 1167504

URL: http://svn.apache.org/viewvc?rev=1167504&view=rev
Log:
- synchronize names of sequenceName attribute in SQL and java generation
- remove unused methods in platform
- do not cut autogenerated sequence and constraint names to be below a certain length.

Modified:
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/Platform.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2400Impl.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2Impl.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDefaultImpl.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDerbyImpl.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMssqlImpl.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformOracleImpl.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformPostgresqlImpl.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformSapdbImpl.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformSybaseImpl.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMTableTransformer.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/TableAttributeName.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/sql/SQLTransformer.java

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/Platform.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/Platform.java?rev=1167504&r1=1167503&r2=1167504&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/Platform.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/Platform.java
Sat Sep 10 12:33:46 2011
@@ -30,25 +30,6 @@ import org.apache.torque.templates.typem
  */
 public interface Platform
 {
-    /** constant for native id method */
-    String IDENTITY = "identity";
-    /** constant for native id method */
-    String SEQUENCE = "sequence";
-
-    /**
-     * Returns the native IdMethod (sequence|identity)
-     *
-     * @return the native IdMethod
-     */
-    String getNativeIdMethod();
-
-    /**
-     * Returns the max column length supported by the db.
-     *
-     * @return the max column length
-     */
-    int getMaxColumnNameLength();
-
     /**
      * Returns the db specific sql Type for a Torque Type.
      *
@@ -88,14 +69,14 @@ public interface Platform
 
     /**
      * Returns a possible SQL suffix for column definitions of certain
-     *  SQL Types, e.g. for Oracle VARCHAR2 columns, it typically 
+     *  SQL Types, e.g. for Oracle VARCHAR2 columns, it typically
      *  makes sense to use 'XXX CHAR' instead of 'XXX' as size.
-     *  
+     *
      * @param sqlType the SQL type to determine the suffix for.
-     * 
+     *
      * @return the size suffix, not null, may be empty.
      */
-    public String getSizeSuffix(String sqlType);
+    String getSizeSuffix(String sqlType);
 
     /**
      * Returns whether the "not null part" of the definition of a column

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2400Impl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2400Impl.java?rev=1167504&r1=1167503&r2=1167504&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2400Impl.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2400Impl.java
Sat Sep 10 12:33:46 2011
@@ -76,14 +76,6 @@ public class PlatformDb2400Impl extends 
                 new SqlType("LONG VARCHAR FOR BIT DATA"));
     }
 
-    /**
-     * @see Platform#getMaxColumnNameLength()
-     */
-    public int getMaxColumnNameLength()
-    {
-        return 30;
-    }
-
     protected boolean escapeBackslashes()
     {
         return true;

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2Impl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2Impl.java?rev=1167504&r1=1167503&r2=1167504&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2Impl.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2Impl.java
Sat Sep 10 12:33:46 2011
@@ -65,15 +65,6 @@ public class PlatformDb2Impl extends Pla
     }
 
     /**
-     * @see Platform#getMaxColumnNameLength()
-     */
-    public int getMaxColumnNameLength()
-    {
-        // TODO check this! (value taken from db.props)
-        return 18;
-    }
-
-    /**
      * @see Platform#getAutoIncrement()
      */
     public String getAutoIncrement()

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDefaultImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDefaultImpl.java?rev=1167504&r1=1167503&r2=1167504&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDefaultImpl.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDefaultImpl.java
Sat Sep 10 12:33:46 2011
@@ -91,22 +91,6 @@ public class PlatformDefaultImpl impleme
     }
 
     /**
-     * @see Platform#getMaxColumnNameLength()
-     */
-    public int getMaxColumnNameLength()
-    {
-        return 64;
-    }
-
-    /**
-     * @see Platform#getNativeIdMethod()
-     */
-    public String getNativeIdMethod()
-    {
-        return Platform.IDENTITY;
-    }
-
-    /**
      * @see Platform#getSqlTypeForSchemaType(SchemaType)
      */
     public SqlType getSqlTypeForSchemaType(SchemaType schemaType)

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDerbyImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDerbyImpl.java?rev=1167504&r1=1167503&r2=1167504&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDerbyImpl.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDerbyImpl.java
Sat Sep 10 12:33:46 2011
@@ -71,14 +71,6 @@ public class PlatformDerbyImpl extends P
     }
 
     /**
-     * @see Platform#getMaxColumnNameLength()
-     */
-    public int getMaxColumnNameLength()
-    {
-        return 128;
-    }
-
-    /**
      * @see Platform#getAutoIncrement(
      */
     public String getAutoIncrement()
@@ -87,14 +79,6 @@ public class PlatformDerbyImpl extends P
     }
 
     /**
-     * @see Platform#getNativeIdMethod()
-     */
-    public String getNativeIdMethod()
-    {
-        return Platform.IDENTITY;
-    }
-
-    /**
      * @see Platform#hasScale(String)
      */
     public boolean hasScale(String sqlType)

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMssqlImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMssqlImpl.java?rev=1167504&r1=1167503&r2=1167504&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMssqlImpl.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMssqlImpl.java
Sat Sep 10 12:33:46 2011
@@ -84,14 +84,6 @@ public class PlatformMssqlImpl extends P
     }
 
     /**
-     * @see Platform#getMaxColumnNameLength()
-     */
-    public int getMaxColumnNameLength()
-    {
-        return 30;
-    }
-
-    /**
      * @return Explicitly returns <code>NULL</code> if null values are
      * allowed (as recomended by Microsoft).
      * @see Platform#getNullString(boolean)

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformOracleImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformOracleImpl.java?rev=1167504&r1=1167503&r2=1167504&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformOracleImpl.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformOracleImpl.java
Sat Sep 10 12:33:46 2011
@@ -93,22 +93,6 @@ public class PlatformOracleImpl extends 
     }
 
     /**
-     * @see Platform#getMaxColumnNameLength()
-     */
-    public int getMaxColumnNameLength()
-    {
-        return 30;
-    }
-
-    /**
-     * @see Platform#getNativeIdMethod()
-     */
-    public String getNativeIdMethod()
-    {
-        return Platform.SEQUENCE;
-    }
-
-    /**
      * @see Platform#getAutoIncrement()
      */
     public String getAutoIncrement()

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformPostgresqlImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformPostgresqlImpl.java?rev=1167504&r1=1167503&r2=1167504&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformPostgresqlImpl.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformPostgresqlImpl.java
Sat Sep 10 12:33:46 2011
@@ -89,14 +89,6 @@ public class PlatformPostgresqlImpl exte
     }
 
     /**
-     * @see Platform#getNativeIdMethod()
-     */
-    public String getNativeIdMethod()
-    {
-        return Platform.SEQUENCE;
-    }
-
-    /**
      * @see Platform#getAutoIncrement()
      */
     public String getAutoIncrement()

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformSapdbImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformSapdbImpl.java?rev=1167504&r1=1167503&r2=1167504&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformSapdbImpl.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformSapdbImpl.java
Sat Sep 10 12:33:46 2011
@@ -89,14 +89,6 @@ public class PlatformSapdbImpl extends P
     }
 
     /**
-     * @see Platform#getNativeIdMethod()
-     */
-    public String getNativeIdMethod()
-    {
-        return Platform.SEQUENCE;
-    }
-
-    /**
      * @see Platform#getAutoIncrement()
      */
     public String getAutoIncrement()

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformSybaseImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformSybaseImpl.java?rev=1167504&r1=1167503&r2=1167504&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformSybaseImpl.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformSybaseImpl.java
Sat Sep 10 12:33:46 2011
@@ -77,14 +77,6 @@ public class PlatformSybaseImpl extends 
     }
 
     /**
-     * @see Platform#getMaxColumnNameLength()
-     */
-    public int getMaxColumnNameLength()
-    {
-        return 30;
-    }
-
-    /**
      * @see Platform#getNullString(boolean)
      */
     public String getNullString(boolean notNull)

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMTableTransformer.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMTableTransformer.java?rev=1167504&r1=1167503&r2=1167504&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMTableTransformer.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMTableTransformer.java
Sat Sep 10 12:33:46 2011
@@ -199,10 +199,10 @@ public class OMTableTransformer extends 
         List<SourceElement> idMethodParams = tableElement.getChildren(
                 TorqueSchemaElementName.ID_METHOD_PARAMETER);
         if (idMethodParams.isEmpty()
-            && tableElement.getAttribute(TableAttributeName.SEQUENCE) == null)
+            && tableElement.getAttribute(TableAttributeName.SEQUENCE_NAME) == null)
         {
             tableElement.setAttribute(
-                    TableAttributeName.SEQUENCE,
+                    TableAttributeName.SEQUENCE_NAME,
                     (String) tableElement.getAttribute(
                           TorqueSchemaAttributeName.NAME)
                         + "_SEQ");
@@ -210,7 +210,7 @@ public class OMTableTransformer extends 
         else
         {
             tableElement.setAttribute(
-                    TableAttributeName.SEQUENCE,
+                    TableAttributeName.SEQUENCE_NAME,
                         idMethodParams.get(0).getAttribute(
                             TorqueSchemaAttributeName.VALUE.getName()));
         }

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/TableAttributeName.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/TableAttributeName.java?rev=1167504&r1=1167503&r2=1167504&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/TableAttributeName.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/TableAttributeName.java
Sat Sep 10 12:33:46 2011
@@ -28,11 +28,6 @@ import org.apache.torque.generator.sourc
 public enum TableAttributeName implements SourceAttributeName
 {
     /**
-     * The name of the sequence for the field.
-     */
-    SEQUENCE("sequence"),
-
-    /**
      * The name of the manager class.
      */
     MANAGER_CLASS_NAME("managerClassName"),
@@ -80,7 +75,13 @@ public enum TableAttributeName implement
     /**
      * The name of the setter for the peer implementation class.
      */
-    PEER_IMPL_SETTER("peerImplSetter");
+    PEER_IMPL_SETTER("peerImplSetter"),
+
+    /**
+     * The name of the sequence generated for the table's primary key.
+     */
+    SEQUENCE_NAME("sequenceName");
+
 
     /** The name of the source element attribute, not null. */
     private String name;

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/sql/SQLTransformer.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/sql/SQLTransformer.java?rev=1167504&r1=1167503&r2=1167504&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/sql/SQLTransformer.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/sql/SQLTransformer.java
Sat Sep 10 12:33:46 2011
@@ -96,14 +96,12 @@ public class SQLTransformer implements S
                     defaultIdMethod);
         }
         String tableName = (String) tableElement.getAttribute(
-                TorqueSchemaAttributeName.NAME.getName());
-        if (tableElement.getAttribute(SqlAttributeName.PRIMARY_KEY_CONSTRAINT_NAME)
-                == null)
+                TorqueSchemaAttributeName.NAME);
+        if (tableElement.getAttribute(
+                SqlAttributeName.PRIMARY_KEY_CONSTRAINT_NAME)
+            == null)
         {
-            // TODO: Column length from database descriptor
-            String primaryKeyConstraintName =
-                (tableName.length() > 27 ? tableName.substring(0, 26) : tableName)
-                  + "_PK";
+            String primaryKeyConstraintName = tableName + "_PK";
             tableElement.setAttribute(
                     SqlAttributeName.PRIMARY_KEY_CONSTRAINT_NAME,
                     primaryKeyConstraintName);
@@ -121,11 +119,7 @@ public class SQLTransformer implements S
             }
             if (StringUtils.isBlank(sequenceName))
             {
-                // TODO: Sequence name length from database descriptor
-                sequenceName = (tableName.length() > 27 
-                          ? tableName.substring(0, 26)
-                          : tableName)
-                      + "_SEQ";
+                sequenceName = tableName + "_SEQ";
             }
             tableElement.setAttribute(
                     SqlAttributeName.SEQUENCE_NAME,
@@ -235,7 +229,7 @@ public class SQLTransformer implements S
                 SqlAttributeName.DDL_SQL);
         if (sql == null)
         {
-            sql = getSql(columnElement, controllerState);
+            sql = getDdlSql(columnElement, controllerState);
             columnElement.setAttribute(SqlAttributeName.DDL_SQL, sql);
         }
     }
@@ -251,7 +245,7 @@ public class SQLTransformer implements S
      *
      * @throws SourceTransformerException
      */
-    private String getSql(
+    private String getDdlSql(
             SourceElement columnElement,
             ControllerState controllerState)
         throws SourceTransformerException



---------------------------------------------------------------------
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