db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r930649 - /db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMColumnTransformer.java
Date Sun, 04 Apr 2010 09:47:14 GMT
Author: tfischer
Date: Sun Apr  4 09:47:13 2010
New Revision: 930649

URL: http://svn.apache.org/viewvc?rev=930649&view=rev
Log:
prepend underscore to peer column name constant if the column name is TABLE_NAME or DATABASE

Modified:
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMColumnTransformer.java

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMColumnTransformer.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMColumnTransformer.java?rev=930649&r1=930648&r2=930649&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMColumnTransformer.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMColumnTransformer.java
Sun Apr  4 09:47:13 2010
@@ -19,6 +19,10 @@ package org.apache.torque.templates.tran
  * under the License.
  */
 
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
 import org.apache.commons.lang.StringUtils;
 import org.apache.torque.gf.control.ControllerState;
 import org.apache.torque.gf.processor.string.Camelbacker;
@@ -42,6 +46,17 @@ public class OMColumnTransformer
 
     private static OMInheritanceTransformer inheritanceTransformer
             = new OMInheritanceTransformer();
+    
+    private static Set<String> RESERVED_CONSTANT_NAMES;
+    
+    static
+    {
+        Set<String> reservedConstantNames = new HashSet<String>();
+        reservedConstantNames.add("DATABASE");
+        reservedConstantNames.add("TABLE_NAME");
+        RESERVED_CONSTANT_NAMES 
+            = Collections.unmodifiableSet(reservedConstantNames);
+    }
 
     public void transform(
             SourceElement columnElement,
@@ -316,6 +331,10 @@ public class OMColumnTransformer
         String columnName = (String) columnElement.getAttribute(
                 TorqueSchemaAttributeName.NAME);
         String peerColumnName = columnName.toUpperCase();
+        if (RESERVED_CONSTANT_NAMES.contains(peerColumnName))
+        {
+            peerColumnName = "_" +  peerColumnName;
+        }
         columnElement.setAttribute(
                 ColumnAttributeName.PEER_COLUMN_NAME,
                 peerColumnName);



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