db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1125337 - /db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMColumnTransformer.java
Date Fri, 20 May 2011 12:00:16 GMT
Author: tfischer
Date: Fri May 20 12:00:15 2011
New Revision: 1125337

URL: http://svn.apache.org/viewvc?rev=1125337&view=rev
Log:
Fill inheritance column with class name by default in case of classname-based inheritance

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=1125337&r1=1125336&r2=1125337&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
Fri May 20 12:00:15 2011
@@ -31,6 +31,7 @@ import org.apache.torque.generator.sourc
 import org.apache.torque.generator.source.transform.SourceTransformerException;
 import org.apache.torque.templates.TorqueSchemaAttributeName;
 import org.apache.torque.templates.TorqueSchemaElementName;
+import org.apache.torque.templates.TorqueSchemaInheritance;
 import org.apache.torque.templates.TorqueSchemaJavaType;
 import org.apache.torque.templates.transformer.SchemaTypeHelper;
 import org.apache.torque.templates.typemapping.JavaType;
@@ -514,6 +515,21 @@ public class OMColumnTransformer
                 JavaType javaType)
             throws SourceTransformerException
     {
+        // special case inheritance by class name
+        // In this case, the class name of the object must be written into the
+        // column as default, overriding any SQL default values.
+        if (TorqueSchemaInheritance.SINGLE.getValue().equals(
+                    columnElement.getAttribute(
+                        TorqueSchemaAttributeName.INHERITANCE))
+            && columnElement.getChildren(TorqueSchemaElementName.INHERITANCE)
+                    .isEmpty())
+        {
+            columnElement.setAttribute(
+                    JavaFieldAttributeName.DEFAULT_VALUE,
+                    "getClass().getName()");
+            return;
+        }
+
         if (columnElement.getAttribute(JavaFieldAttributeName.DEFAULT_VALUE)
                 != null)
         {



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