Author: tfischer
Date: Mon Oct 13 07:55:38 2014
New Revision: 1631308

URL: http://svn.apache.org/r1631308
Log:
TORQUE-331 - implement enum handling (testing bugfixing to be done)
TORQUE-308 - be backwards compatible with schema location

Added:
    
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/skipdecider/EnumSkipDecider.java
    
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/EnumValueAttributeName.java
    
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/enum.vm
    
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/enumClassJavadoc.vm
    
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/enumValue.vm
    
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/xsd/database-4-1-strict.xsd
    
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/xsd/database-4-1.xsd
Modified:
    
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TemplateOptionName.java
    
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaAttributeName.java
    
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaElementName.java
    
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/ColumnAttributeName.java
    
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMColumnTransformer.java
    
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/html/conf/control.xml
    
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/xdoc/conf/control.xml
    
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/idtable/conf/control.xml
    
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/conf/control.xml
    
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/conf/options.properties
    
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/dbObject.xml
    
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/imports.vm
    
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/buildColumnValues.vm
    
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/recordmapper/base/dbObjectFieldGetter.vm
    
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/recordmapper/base/recordMapperBase.vm
    
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/conf/control.xml
    
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/createdb/conf/control.xml
    
db/torque/torque4/trunk/torque-templates/src/test/resources/org/apache/torque/templates/expected-datamodel.xml
    
db/torque/torque4/trunk/torque-templates/src/test/resources/org/apache/torque/templates/expected-schema.html
    
db/torque/torque4/trunk/torque-templates/src/test/resources/org/apache/torque/templates/expected-schema.sql
    db/torque/torque4/trunk/torque-templates/src/test/schema/schema.xml

Modified: 
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TemplateOptionName.java
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TemplateOptionName.java?rev=1631308&r1=1631307&r2=1631308&view=diff
==============================================================================
--- 
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TemplateOptionName.java
 (original)
+++ 
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TemplateOptionName.java
 Mon Oct 13 07:55:38 2014
@@ -241,7 +241,13 @@ public enum TemplateOptionName implement
     /**
      * The visibility of the joinGetter methods.
      */
-    
OM_JOIN_GETTER_VISIBILITY("torque.om.complexObjectModel.joinGetterVisibility");
+    
OM_JOIN_GETTER_VISIBILITY("torque.om.complexObjectModel.joinGetterVisibility"),
+
+    /** The prefix for the name of enum types. */
+    OM_ENUM_NAME_PREFIX("torque.om.enumNamePrefix"),
+
+    /** The suffix for the name of enum types. */
+    OM_ENUM_NAME_SUFFIX("torque.om.enumNameSuffix");
 
     /**
      * The fully qualified name of the option.

Modified: 
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaAttributeName.java
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaAttributeName.java?rev=1631308&r1=1631307&r2=1631308&view=diff
==============================================================================
--- 
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaAttributeName.java
 (original)
+++ 
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaAttributeName.java
 Mon Oct 13 07:55:38 2014
@@ -91,7 +91,9 @@ public enum TorqueSchemaAttributeName im
     /** attribute skipSql */
     SKIP_SQL("skipSql"),
     /** attribute version */
-    VERSION ("version");
+    VERSION ("version"),
+    /** attribute version */
+    ENUM_NAME("enumName");
 
     /** The name of the attribute, not null. */
     private String name;
@@ -101,7 +103,7 @@ public enum TorqueSchemaAttributeName im
      *
      * @param name the name of the attribute, not null.
      */
-    private TorqueSchemaAttributeName(String name)
+    private TorqueSchemaAttributeName(final String name)
     {
         this.name = name;
     }

Modified: 
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaElementName.java
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaElementName.java?rev=1631308&r1=1631307&r2=1631308&view=diff
==============================================================================
--- 
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaElementName.java
 (original)
+++ 
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaElementName.java
 Mon Oct 13 07:55:38 2014
@@ -57,7 +57,9 @@ public enum TorqueSchemaElementName impl
     /** element index. */
     INDEX("index"),
     /** element index-column. */
-    INDEX_COLUMN("index-column");
+    INDEX_COLUMN("index-column"),
+    /** element enum-value. */
+    ENUM_VALUE("enum-value");
 
     /**
      * The name of the element, not null.
@@ -69,7 +71,7 @@ public enum TorqueSchemaElementName impl
      *
      * @param name the name of the element, not null.
      */
-    private TorqueSchemaElementName(String name)
+    private TorqueSchemaElementName(final String name)
     {
         this.name = name;
     }

Added: 
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/skipdecider/EnumSkipDecider.java
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/skipdecider/EnumSkipDecider.java?rev=1631308&view=auto
==============================================================================
--- 
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/skipdecider/EnumSkipDecider.java
 (added)
+++ 
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/skipdecider/EnumSkipDecider.java
 Mon Oct 13 07:55:38 2014
@@ -0,0 +1,44 @@
+package org.apache.torque.templates.skipdecider;
+
+/*
+ * 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.
+ */
+
+import org.apache.torque.generator.control.ControllerState;
+import org.apache.torque.generator.source.SourceElement;
+import org.apache.torque.generator.source.skipDecider.SkipDecider;
+import org.apache.torque.templates.transformer.om.ColumnAttributeName;
+
+/**
+ * A skip decider which returns true if the attribute "generateEnum"
+ * is set to "true" the current source element.
+ *
+ * @version $Id: InterfaceSkipDecider.java 1470235 2013-04-20 21:23:39Z 
tfischer $
+ */
+public class EnumSkipDecider implements SkipDecider
+{
+    public boolean proceed(final ControllerState controllerState)
+    {
+        SourceElement sourceElement
+                = (SourceElement) controllerState.getModel();
+        String generateEnum
+                = (String) sourceElement.getAttribute(
+                        ColumnAttributeName.GENERATE_ENUM);
+        return Boolean.parseBoolean(generateEnum);
+    }
+}

Modified: 
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/ColumnAttributeName.java
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/ColumnAttributeName.java?rev=1631308&r1=1631307&r2=1631308&view=diff
==============================================================================
--- 
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/ColumnAttributeName.java
 (original)
+++ 
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/ColumnAttributeName.java
 Mon Oct 13 07:55:38 2014
@@ -27,19 +27,13 @@ import org.apache.torque.generator.sourc
  */
 public enum ColumnAttributeName implements SourceAttributeName
 {
-    /**
-     * Whether the column is a primitive column.
-     */
+    /** Whether the column is a primitive column. */
     PRIMITIVE_TYPE("primitive"),
 
-    /**
-     * Whether the column is a number column.
-     */
+    /** Whether the column is a number column. */
     NUMBER_TYPE("number"),
 
-    /**
-     * The name of constant for the column name in the peer class.
-     */
+    /** The name of constant for the column name in the peer class. */
     PEER_COLUMN_NAME("peerColumnName"),
 
     /**
@@ -48,25 +42,32 @@ public enum ColumnAttributeName implemen
      */
     QUALIFIED_COLUMN_NAME("qualifiedColumnName"),
 
-    /**
-     * The column index, 1 based. First column 1, second column 2 etc.
-     */
+    /** The column index, 1 based. First column 1, second column 2 etc. */
     POSITION("position"),
 
-    /**
-     * The object (non-primitive) type for a field.
-     */
+    /** The object (non-primitive) type for a field. */
     FIELD_OBJECT_TYPE("fieldObjectType"),
 
-    /**
-     * The getter to get the column from a result set.
-     */
+    /** The getter to get the column from a result set. */
     RESULT_SET_GETTER("resultSetGetter"),
 
-    /**
-     * An instance of the object for the type map.
-     */
-    SAMPLE_OBJECT("sampleObject");
+    /** An instance of the object for the type map. */
+    SAMPLE_OBJECT("sampleObject"),
+
+    /** The unqualified name of the enum type of the column. */
+    ENUM_CLASS_NAME("enumClassName"),
+
+    /** The package of the enum type of the column. */
+    ENUM_PACKAGE("enumPackage"),
+
+    /** The unqualified class name of the value contained in enum type of the 
column. */
+    ENUM_VALUE_CLASS_NAME("enumValueClassName"),
+
+    /** Whether to generate an enum type for the column (nb: predefined enums 
can be defined which need not be generated). */
+    GENERATE_ENUM("generateEnum"),
+
+    /** Whether this column is an enum. */
+    IS_ENUM("isEnum");
 
     /** The name of the source element attribute, not null. */
     private String name;
@@ -76,7 +77,7 @@ public enum ColumnAttributeName implemen
      *
      * @param name the name of the source element attribute, not null.
      */
-    private ColumnAttributeName(String name)
+    private ColumnAttributeName(final String name)
     {
         this.name = name;
     }

Added: 
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/EnumValueAttributeName.java
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/EnumValueAttributeName.java?rev=1631308&view=auto
==============================================================================
--- 
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/EnumValueAttributeName.java
 (added)
+++ 
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/EnumValueAttributeName.java
 Mon Oct 13 07:55:38 2014
@@ -0,0 +1,61 @@
+package org.apache.torque.templates.transformer.om;
+
+/*
+ * 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.
+ */
+
+import org.apache.torque.generator.source.SourceAttributeName;
+
+/**
+ * Contains the attributes for a enum-value source element which are not
+ * defined in the Torque schema.
+ */
+public enum EnumValueAttributeName implements SourceAttributeName
+{
+    /** The java value of the enum Attribute. */
+    JAVA_VALUE("javaValue");
+
+    /** The name of the source element attribute, not null. */
+    private String name;
+
+    /**
+     * Constructor.
+     *
+     * @param name the name of the source element attribute, not null.
+     */
+    private EnumValueAttributeName(final String name)
+    {
+        this.name = name;
+    }
+
+    /**
+     * Returns the name of the referenced source element attribute.
+     *
+     * @return the name of the referenced source element attribute.
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+    @Override
+    public String toString()
+    {
+        return name;
+    }
+}

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=1631308&r1=1631307&r2=1631308&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
 Mon Oct 13 07:55:38 2014
@@ -30,6 +30,7 @@ import java.util.TimeZone;
 import org.apache.commons.lang.StringUtils;
 import org.apache.torque.generator.control.ControllerState;
 import org.apache.torque.generator.processor.string.Camelbacker;
+import org.apache.torque.generator.processor.string.ConstantNameCreator;
 import org.apache.torque.generator.processor.string.WrapReservedJavaWords;
 import org.apache.torque.generator.source.SourceElement;
 import org.apache.torque.generator.source.transform.SourceTransformerException;
@@ -55,6 +56,9 @@ public class OMColumnTransformer
     /** The camelbacker to create the java name from the column name. */
     private static Camelbacker javaNameCamelbacker = new Camelbacker();
 
+    /** Creates constant names from values. */
+    private static ConstantNameCreator constantNameCreator = new 
ConstantNameCreator();
+
     /** The transformer for inheritance elements. */
     private static OMInheritanceTransformer inheritanceTransformer
             = new OMInheritanceTransformer();
@@ -107,6 +111,7 @@ public class OMColumnTransformer
         checkElementName(columnElement);
         checkColumnNameExists(columnElement);
         setJavaTypeAttribute(columnElement);
+        setJavaNameAttribute(columnElement);
 
         columnElement.setAttribute(
                 ColumnAttributeName.POSITION,
@@ -119,19 +124,15 @@ public class OMColumnTransformer
         columnElement.setAttribute("schemaType", schemaType);
         setDomainAttributes(columnElement, controllerState);
 
-        JavaType fieldJavaType = getFieldJavaType(columnElement, schemaType);
-        columnElement.setAttribute(
-                JavaFieldAttributeName.FIELD_TYPE,
-                fieldJavaType.getFullClassName());
+        String enumClassName = setEnumAttributes(columnElement, 
controllerState);
+        JavaType fieldJavaType = setFieldJavaType(columnElement, schemaType, 
enumClassName);
         JavaType fieldJavaObjectType = TypeMap.getJavaObjectType(schemaType);
         columnElement.setAttribute(
                 ColumnAttributeName.FIELD_OBJECT_TYPE,
                 fieldJavaObjectType.getFullClassName());
 
-
         setPrimitiveTypeAttribute(columnElement, fieldJavaType);
         setNumberTypeAttribute(columnElement, fieldJavaType);
-        setJavaNameAttribute(columnElement);
         setFieldNameAttribute(columnElement);
         setPeerColumnNameAttribute(columnElement);
         setQualifiedColumnNameAttribute(columnElement);
@@ -150,6 +151,12 @@ public class OMColumnTransformer
                     inheritanceElement,
                     controllerState);
         }
+        for (SourceElement enumValueElement : columnElement.getChildren(
+                TorqueSchemaElementName.ENUM_VALUE.getName()))
+        {
+            setEnumValueJavaNameAttribute(enumValueElement);
+            setEnumValueJavaValueAttribute(enumValueElement, fieldJavaType);
+        }
     }
 
     /**
@@ -329,12 +336,14 @@ public class OMColumnTransformer
      *
      * @param columnElement the column element, not null.
      * @param schemaType the schema type, not null.
+     * @param enumClassName the class name of the enum, or null if the column 
is not an enum.
      *
      * @return the java type of the column
      */
-    protected JavaType getFieldJavaType(
+    protected JavaType setFieldJavaType(
                 final SourceElement columnElement,
-                final SchemaType schemaType)
+                final SchemaType schemaType,
+                final String enumClassName)
             throws SourceTransformerException
     {
         JavaType result;
@@ -358,6 +367,15 @@ public class OMColumnTransformer
                     + " in column "
                     + columnName);
         }
+        if (enumClassName != null)
+        {
+            columnElement.setAttribute(JavaFieldAttributeName.FIELD_TYPE, 
enumClassName);
+            
columnElement.setAttribute(ColumnAttributeName.ENUM_VALUE_CLASS_NAME, 
result.getFullClassName());
+        }
+        else
+        {
+            columnElement.setAttribute(JavaFieldAttributeName.FIELD_TYPE, 
result.getFullClassName());
+        }
         return result;
     }
 
@@ -656,6 +674,12 @@ public class OMColumnTransformer
         {
             fieldDefaultValue = getDefaultValueWithoutDefaultSet(javaType);
         }
+        if (!"null".equals(fieldDefaultValue)
+            && Boolean.parseBoolean((String) 
columnElement.getAttribute(ColumnAttributeName.IS_ENUM)))
+        {
+            fieldDefaultValue = (String) 
columnElement.getAttribute(ColumnAttributeName.ENUM_CLASS_NAME)
+                    + ".getByValue(" + fieldDefaultValue + ")";
+        }
         columnElement.setAttribute(
                 JavaFieldAttributeName.DEFAULT_VALUE,
                 fieldDefaultValue);
@@ -1004,4 +1028,124 @@ public class OMColumnTransformer
                 sampleObject);
     }
 
+    /**
+     * Sets the enumClassName, enumPackage and generateEnum Attributes
+     * if either enumValue child elements are present or the enumName
+     * attribute is set on the column.
+     * Afterwards, the enumClassName attribute contains the unqualified name
+     * of the enum, the enumPackage attribute contains the enum package,
+     * and the generateEnum attribute contains "true" if the enum needs
+     * to be generated.
+     *
+     * This requires that the javaName attribute is set on the column
+     * and that the dbObjectPackage element is set on the table.
+     *
+     * @param columnElement the column element to set the elements in, not 
null.
+     * @param controllerState the controller state, not null.
+     *
+     * @return the class name of the enum, or null if the column is not an 
enum column.
+     */
+    protected String setEnumAttributes(
+            final SourceElement columnElement,
+            final ControllerState controllerState)
+    {
+        String enumClassName = (String) 
columnElement.getAttribute(TorqueSchemaAttributeName.ENUM_NAME);
+        String enumPackage;
+        boolean columnIsEnum = false;
+        // whether to generate an enum class. This is not the same as 
columnIsEnum because
+        // we have the case of pre-defined enums (no enum-value attributes 
given).
+        boolean generateEnum = true;
+        if (enumClassName != null)
+        {
+            columnIsEnum = true;
+            int lastIndexOfDot = enumClassName.lastIndexOf('.');
+            if (lastIndexOfDot != -1)
+            {
+                enumPackage = enumClassName.substring(0, lastIndexOfDot);
+                enumClassName = enumClassName.substring(lastIndexOfDot + 1);
+            }
+            else
+            {
+                enumPackage = (String) columnElement.getParent().getAttribute(
+                        TableAttributeName.DB_OBJECT_PACKAGE);
+            }
+            if (columnElement.getChild(TorqueSchemaElementName.ENUM_VALUE) == 
null)
+            {
+                generateEnum = false;
+            }
+        }
+        else
+        {
+            if (columnElement.getChild(TorqueSchemaElementName.ENUM_VALUE) == 
null)
+            {
+                generateEnum = false;
+            }
+            else
+            {
+                columnIsEnum = true;
+            }
+            enumClassName = 
controllerState.getStringOption(TemplateOptionName.OM_ENUM_NAME_PREFIX)
+                    + 
columnElement.getAttribute(TorqueSchemaAttributeName.JAVA_NAME)
+                    + 
controllerState.getStringOption(TemplateOptionName.OM_ENUM_NAME_SUFFIX);
+            enumPackage = (String) columnElement.getParent().getAttribute(
+                    TableAttributeName.DB_OBJECT_PACKAGE);
+        }
+        columnElement.setAttribute(
+                ColumnAttributeName.ENUM_CLASS_NAME,
+                enumClassName);
+        columnElement.setAttribute(
+                ColumnAttributeName.ENUM_PACKAGE,
+                enumPackage);
+        columnElement.setAttribute(
+                ColumnAttributeName.GENERATE_ENUM,
+                Boolean.toString(generateEnum));
+        columnElement.setAttribute(
+                ColumnAttributeName.IS_ENUM,
+                Boolean.toString(columnIsEnum));
+
+        if (columnIsEnum)
+        {
+            return enumClassName;
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+    protected void setEnumValueJavaNameAttribute(
+            final SourceElement enumValueElement)
+        throws SourceTransformerException
+    {
+        if (enumValueElement.getAttribute(TorqueSchemaAttributeName.JAVA_NAME) 
!= null)
+        {
+            return;
+        }
+        String value = (String) 
enumValueElement.getAttribute(TorqueSchemaAttributeName.VALUE);
+        if (value == null)
+        {
+            throw new SourceTransformerException("value attribute must be set 
on all enum-value elements in enum column "
+                    + enumValueElement.getParent());
+        }
+        String javaName = constantNameCreator.process(value);
+        enumValueElement.setAttribute(TorqueSchemaAttributeName.JAVA_NAME, 
javaName);
+    }
+
+    protected void setEnumValueJavaValueAttribute(
+                final SourceElement enumValueElement,
+                final JavaType columnJavaType)
+            throws SourceTransformerException
+    {
+        if (enumValueElement.getAttribute(EnumValueAttributeName.JAVA_VALUE) 
!= null)
+        {
+            return;
+        }
+        SourceElement columnElement = enumValueElement.getParent();
+        String javaValue = getDefaultValueWithDefaultSet(
+                columnJavaType,
+                (String) 
enumValueElement.getAttribute(TorqueSchemaAttributeName.VALUE),
+                false,
+                columnElement);
+        enumValueElement.setAttribute(EnumValueAttributeName.JAVA_VALUE, 
javaValue);
+    }
 }

Modified: 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/html/conf/control.xml
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/html/conf/control.xml?rev=1631308&r1=1631307&r2=1631308&view=diff
==============================================================================
--- 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/html/conf/control.xml
 (original)
+++ 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/html/conf/control.xml
 Mon Oct 13 07:55:38 2014
@@ -23,14 +23,28 @@
     xsi:schemaLocation="http://db.apache.org/torque/4.0/generator/configuration
         http://db.apache.org/torque/4.0/generator/configuration.xsd";
     xmlns="http://db.apache.org/torque/4.0/generator/configuration";>
+
+  <options xsi:type="propertiesOptions" 
path="../../../om/conf/options.properties"/>
   <options xsi:type="propertiesOptions" path="options.properties"/>
 
   <entityReference
+      systemId="http://db.apache.org/torque/4.0/templates/database.xsd";
+      resource="../../../xsd/database-4-0.xsd" />
+  <entityReference
+      systemId="http://db.apache.org/torque/4.0/templates/database-strict.xsd";
+      resource="../../../xsd/database-4-0-strict.xsd" />
+  <entityReference
       
systemId="http://db.apache.org/torque/torque-4.0/documentation/orm-reference/database-4-0.xsd";
       resource="../../../xsd/database-4-0.xsd" />
   <entityReference
       
systemId="http://db.apache.org/torque/torque-4.0/documentation/orm-reference/database-4-0-strict.xsd";
       resource="../../../xsd/database-4-0-strict.xsd" />
+  <entityReference
+      
systemId="http://db.apache.org/torque/torque-4.1/documentation/orm-reference/database-4-1.xsd";
+      resource="../../../xsd/database-4-1.xsd" />
+  <entityReference
+      
systemId="http://db.apache.org/torque/torque-4.1/documentation/orm-reference/database-4-1-strict.xsd";
+      resource="../../../xsd/database-4-1-strict.xsd" />
 
   <!-- Documentation css -->
   <output name="css" file="datamodel.css">

Modified: 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/xdoc/conf/control.xml
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/xdoc/conf/control.xml?rev=1631308&r1=1631307&r2=1631308&view=diff
==============================================================================
--- 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/xdoc/conf/control.xml
 (original)
+++ 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/xdoc/conf/control.xml
 Mon Oct 13 07:55:38 2014
@@ -23,14 +23,28 @@
     xsi:schemaLocation="http://db.apache.org/torque/4.0/generator/configuration
         http://db.apache.org/torque/4.0/generator/configuration.xsd";
     xmlns="http://db.apache.org/torque/4.0/generator/configuration";>
+
+  <options xsi:type="propertiesOptions" 
path="../../../om/conf/options.properties"/>
   <options xsi:type="propertiesOptions" path="options.properties"/>
 
   <entityReference
+      systemId="http://db.apache.org/torque/4.0/templates/database.xsd";
+      resource="../../../xsd/database-4-0.xsd" />
+  <entityReference
+      systemId="http://db.apache.org/torque/4.0/templates/database-strict.xsd";
+      resource="../../../xsd/database-4-0-strict.xsd" />
+  <entityReference
       
systemId="http://db.apache.org/torque/torque-4.0/documentation/orm-reference/database-4-0.xsd";
       resource="../../../xsd/database-4-0.xsd" />
   <entityReference
       
systemId="http://db.apache.org/torque/torque-4.0/documentation/orm-reference/database-4-0-strict.xsd";
       resource="../../../xsd/database-4-0-strict.xsd" />
+  <entityReference
+      
systemId="http://db.apache.org/torque/torque-4.1/documentation/orm-reference/database-4-1.xsd";
+      resource="../../../xsd/database-4-1.xsd" />
+  <entityReference
+      
systemId="http://db.apache.org/torque/torque-4.1/documentation/orm-reference/database-4-1-strict.xsd";
+      resource="../../../xsd/database-4-1-strict.xsd" />
 
   <!-- Documentation xdoc -->
   <output name="torque.doc.xdoc.xdoc"  file="datamodel.xml">

Modified: 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/idtable/conf/control.xml
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/idtable/conf/control.xml?rev=1631308&r1=1631307&r2=1631308&view=diff
==============================================================================
--- 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/idtable/conf/control.xml
 (original)
+++ 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/idtable/conf/control.xml
 Mon Oct 13 07:55:38 2014
@@ -26,11 +26,23 @@
   <options xsi:type="propertiesOptions" path="options.properties"/>
 
   <entityReference
+      systemId="http://db.apache.org/torque/4.0/templates/database.xsd";
+      resource="../../xsd/database-4-0.xsd" />
+  <entityReference
+      systemId="http://db.apache.org/torque/4.0/templates/database-strict.xsd";
+      resource="../../xsd/database-4-0-strict.xsd" />
+  <entityReference
       
systemId="http://db.apache.org/torque/torque-4.0/documentation/orm-reference/database-4-0.xsd";
       resource="../../xsd/database-4-0.xsd" />
   <entityReference
       
systemId="http://db.apache.org/torque/torque-4.0/documentation/orm-reference/database-4-0-strict.xsd";
       resource="../../xsd/database-4-0-strict.xsd" />
+  <entityReference
+      
systemId="http://db.apache.org/torque/torque-4.1/documentation/orm-reference/database-4-1.xsd";
+      resource="../../xsd/database-4-1.xsd" />
+  <entityReference
+      
systemId="http://db.apache.org/torque/torque-4.1/documentation/orm-reference/database-4-1-strict.xsd";
+      resource="../../xsd/database-4-1-strict.xsd" />
 
   <output name="torque.sql.idtable.idtable">
     <filenameOutlet

Modified: 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/conf/control.xml
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/conf/control.xml?rev=1631308&r1=1631307&r2=1631308&view=diff
==============================================================================
--- 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/conf/control.xml
 (original)
+++ 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/conf/control.xml
 Mon Oct 13 07:55:38 2014
@@ -26,11 +26,23 @@
   <options xsi:type="propertiesOptions" path="options.properties"/>
 
   <entityReference
+      systemId="http://db.apache.org/torque/4.0/templates/database.xsd";
+      resource="../../xsd/database-4-0.xsd" />
+  <entityReference
+      systemId="http://db.apache.org/torque/4.0/templates/database-strict.xsd";
+      resource="../../xsd/database-4-0-strict.xsd" />
+  <entityReference
       
systemId="http://db.apache.org/torque/torque-4.0/documentation/orm-reference/database-4-0.xsd";
       resource="../../xsd/database-4-0.xsd" />
   <entityReference
       
systemId="http://db.apache.org/torque/torque-4.0/documentation/orm-reference/database-4-0-strict.xsd";
       resource="../../xsd/database-4-0-strict.xsd" />
+  <entityReference
+      
systemId="http://db.apache.org/torque/torque-4.1/documentation/orm-reference/database-4-1.xsd";
+      resource="../../xsd/database-4-1.xsd" />
+  <entityReference
+      
systemId="http://db.apache.org/torque/torque-4.1/documentation/orm-reference/database-4-1-strict.xsd";
+      resource="../../xsd/database-4-1-strict.xsd" />
 
   <output name="torque.om.dbObject" existingTargetStrategy="skip" 
outputDirKey="modifiable">
     <filenameOutlet
@@ -198,6 +210,64 @@
     <postprocessor 
class="org.apache.torque.generator.processor.string.RemoveUnusedImportsProcessor"
 />
   </output>
   
+  <output name="torque.om.enum">
+    <filenameOutlet
+        xsi:type="javaOutlet"
+        class="org.apache.torque.generator.outlet.java.JavaFilenameOutlet">
+      <mergepoint name="package">
+        <action
+           xsi:type="sourceElementAttributeAction"
+           element="."
+           attribute="enumPackage"
+           acceptNotSet="false"/>
+      </mergepoint>
+      <mergepoint name="classname">
+        <action 
+            xsi:type="sourceElementAttributeAction"
+            element="."
+            attribute="enumClassName"
+            acceptNotSet="false"/>
+      </mergepoint>
+    </filenameOutlet>
+    <source xsi:type="fileSource" elements="all-tables/table/column"
+            
skipDecider="org.apache.torque.templates.skipdecider.EnumSkipDecider">
+      <transformer 
class="org.apache.torque.templates.transformer.om.OMTransformer"/>
+      <include>*schema.xml</include>
+      <exclude>id-table-schema.xml</exclude>
+    </source>
+    <outlet name="torque.om.dbObject.enum"/>
+    <postprocessor 
class="org.apache.torque.generator.processor.string.RemoveUnusedImportsProcessor"
 />
+  </output>
+
+  <output name="torque.om.enumForView">
+    <filenameOutlet
+        xsi:type="javaOutlet"
+        class="org.apache.torque.generator.outlet.java.JavaFilenameOutlet">
+      <mergepoint name="package">
+        <action
+           xsi:type="sourceElementAttributeAction"
+           element="."
+           attribute="enumPackage"
+           acceptNotSet="false"/>
+      </mergepoint>
+      <mergepoint name="classname">
+        <action 
+            xsi:type="sourceElementAttributeAction"
+            element="."
+            attribute="enumClassName"
+            acceptNotSet="false"/>
+      </mergepoint>
+    </filenameOutlet>
+    <source xsi:type="fileSource" elements="all-views/view/column"
+            
skipDecider="org.apache.torque.templates.skipdecider.EnumSkipDecider">
+      <transformer 
class="org.apache.torque.templates.transformer.om.OMTransformer"/>
+      <include>*schema.xml</include>
+      <exclude>id-table-schema.xml</exclude>
+    </source>
+    <outlet name="torque.om.dbObject.enum"/>
+    <postprocessor 
class="org.apache.torque.generator.processor.string.RemoveUnusedImportsProcessor"
 />
+  </output>
+
   <output name="torque.om.interface" existingTargetStrategy="skip" 
outputDirKey="modifiable">
     <filenameOutlet
         xsi:type="javaOutlet"

Modified: 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/conf/options.properties
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/conf/options.properties?rev=1631308&r1=1631307&r2=1631308&view=diff
==============================================================================
--- 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/conf/options.properties
 (original)
+++ 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/conf/options.properties
 Mon Oct 13 07:55:38 2014
@@ -288,3 +288,9 @@ torque.om.package.mapInitPackageSuffix =
 
 # Default column type if the column type is not set for a column
 torque.om.column.defaultType = VARCHAR
+
+# The prefix for the name of enum types.
+torque.om.enumNamePrefix = 
+# The suffix for the name of enum types.
+torque.om.enumNameSuffix = Enum
+

Modified: 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/dbObject.xml
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/dbObject.xml?rev=1631308&r1=1631307&r2=1631308&view=diff
==============================================================================
--- 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/dbObject.xml
 (original)
+++ 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/dbObject.xml
 Mon Oct 13 07:55:38 2014
@@ -484,4 +484,28 @@
       xsi:type="velocityOutlet"
       path="dbObject/base/toString.vm">
   </outlet>
+  
+  <outlet name="torque.om.dbObject.enum"
+      xsi:type="velocityOutlet"
+      path="dbObject/base/enum.vm">
+    <mergepoint name="classJavadoc">
+      <action xsi:type="applyAction" 
outlet="torque.om.dbObject.enumClassJavadoc"/>
+    </mergepoint>
+    <mergepoint name="values">
+      <action xsi:type="traverseAllAction" 
+          element="enum-value" 
+          outlet="torque.om.dbObject.enumValue"/>
+    </mergepoint>
+    <mergepoint name="extensions"/>
+  </outlet>
+
+  <outlet name="torque.om.dbObject.enumClassJavadoc"
+      xsi:type="velocityOutlet"
+      path="dbObject/base/enumClassJavadoc.vm">
+  </outlet>
+
+  <outlet name="torque.om.dbObject.enumValue"
+      xsi:type="velocityOutlet"
+      path="dbObject/base/enumValue.vm">
+  </outlet>
 </outlets>
\ No newline at end of file

Added: 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/enum.vm
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/enum.vm?rev=1631308&view=auto
==============================================================================
--- 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/enum.vm
 (added)
+++ 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/enum.vm
 Mon Oct 13 07:55:38 2014
@@ -0,0 +1,85 @@
+## 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.
+##
+######
+##
+## version $Id: dbObject.vm 1331196 2012-04-27 02:56:12Z tfischer $
+##
+## This template creates source code for a column enum. 
+## The template expects as input a "column" element from the torque schema
+## which was processed by the OMTransformer.  
+##
+package $enumPackage;
+
+$torqueGen.mergepoint("classJavadoc")##
+public enum $enumClassName
+{
+$torqueGen.mergepoint("values")##
+
+    /** The database value represented by the enum value. */
+    private ${enumValueClassName} value;
+
+    /**
+     * Constructor.
+     *
+     * @param value The database value represented by the enum value.
+     */
+    private ${enumClassName}(${enumValueClassName} value)
+    {
+        this.value = value;
+    }
+
+    /**
+     * Returns the database value represented by the enum value.
+     *
+     * @return the the database value represented by the enum value.
+     */
+    public ${enumValueClassName} getValue()
+    {
+        return value;
+    }
+
+    /**
+     * Returns the ${enumClassName} for the database value.
+     *
+     * @param arg the database value to get the ${enumClassName} for, or null.
+     *
+     * @return the ${enumClassName} represented by the database value; null 
only if arg was null.
+     */
+    public static ${enumClassName} getByValue(${enumValueClassName} arg)
+    {
+#if ($primitive != "true")
+        if (arg == null)
+        {
+            return null;
+        }
+#end
+        for (${enumClassName} candidate : values())
+        {
+#if ($primitive == "true")
+            if (arg == candidate.getValue())
+#else
+            if (arg.equals(candidate.getValue()))
+#end
+            {
+                return candidate;
+            }
+        }
+        throw new IllegalArgumentException("Value " + arg + " is not defined 
in enum ${enumClassName}");
+    }
+$torqueGen.mergepoint("extensions")##
+}

Added: 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/enumClassJavadoc.vm
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/enumClassJavadoc.vm?rev=1631308&view=auto
==============================================================================
--- 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/enumClassJavadoc.vm
 (added)
+++ 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/enumClassJavadoc.vm
 Mon Oct 13 07:55:38 2014
@@ -0,0 +1,39 @@
+## 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.
+##
+######
+##
+## version $Id: classJavadoc.vm 1331196 2012-04-27 02:56:12Z tfischer $
+##
+## Creates the class javadoc for a column enum object. 
+## This template expects as input a "column" element from the torque schema
+## which was processed by the OMTransformer.  
+##
+/**
+#if ($description)
+ * $description
+ *
+#end
+ * This enum contains the possible values for the column
+ * 
${torqueGen.getParent().getAttribute("name")}.${torqueGen.getSourceElement().getAttribute("name")}.
+#if ($torqueGen.booleanOption("torque.om.addTimeStamp"))
+ *
+ * This class was autogenerated by Torque on:
+ *
+ * [${torqueGen.now()}]
+#end
+ */

Added: 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/enumValue.vm
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/enumValue.vm?rev=1631308&view=auto
==============================================================================
--- 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/enumValue.vm
 (added)
+++ 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/enumValue.vm
 Mon Oct 13 07:55:38 2014
@@ -0,0 +1,28 @@
+## 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.
+##
+######
+##
+## version $Id: dbObject.vm 1331196 2012-04-27 02:56:12Z tfischer $
+##
+## This template creates source code for a column enum. 
+## The template expects as input a "column" element from the torque schema
+## which was processed by the OMTransformer.  
+##
+    /** Represents the database value ${value}. */
+    
${javaName}(${javaValue})#if(${torqueGen.getSourceElement().hasFollowingSibling()}),#else;#end
+

Modified: 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/imports.vm
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/imports.vm?rev=1631308&r1=1631307&r2=1631308&view=diff
==============================================================================
--- 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/imports.vm
 (original)
+++ 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/imports.vm
 Mon Oct 13 07:55:38 2014
@@ -60,16 +60,12 @@ import org.apache.torque.util.Transactio
 #end
 import org.apache.commons.lang.ObjectUtils;
 
-
-#if ($torqueGen.booleanOption("torque.om.complexObjectModel"))
-#foreach ($col in $table.Columns)
- #if ($col.isForeignKey())
-  #set ( $tblFK = $table.Database.getTable($col.RelatedTableName) )
-  #if ($tblFK.Interface && $tblFK.Interface.indexOf('.') != -1)
-import $tblFK.Interface;
+#foreach ($columnElement in 
$torqueGen.getSourceElement().getChildren("column"))
+  #set ($colEnumPackage = $columnElement.getAttribute("enumPackage"))
+  #set ($colEnumClassName = $columnElement.getAttribute("enumClassName"))
+  #if ($columnElement.getAttribute("isEnum") == "true" && $colEnumPackage != 
$baseDbObjectPackage) 
+import ${colEnumPackage}.${colEnumClassName};
   #end
- #end
-#end
 #end
 #if ($torqueGen.booleanOption("torque.om.generateBeans"))
 $torqueGen.mergepoint("objectBeanImports")

Modified: 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/buildColumnValues.vm
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/buildColumnValues.vm?rev=1631308&r1=1631307&r2=1631308&view=diff
==============================================================================
--- 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/buildColumnValues.vm
 (original)
+++ 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/buildColumnValues.vm
 Mon Oct 13 07:55:38 2014
@@ -50,6 +50,7 @@
   #set ( $columnSchemaType = $columnElement.getAttribute("schemaType") )
   #set ( $columnFieldName = $columnElement.getAttribute("field") )
   #set ( $columnFieldType = $columnElement.getAttribute("fieldType") )
+  #set ( $columnIsEnum = $columnElement.getAttribute("isEnum") )
   #set ( $primitive = $columnElement.getAttribute("primitive") )
   #set ( $defaultValue = $columnElement.getAttribute("defaultValue") )
   #set ( $useDatabaseDefaultValue = 
$columnElement.getAttribute("useDatabaseDefaultValue") == "true")
@@ -105,6 +106,12 @@
             columnValues.put(
                     ${peerClassName}.$peerColumnName,
                     new JdbcTypedValue($columnFieldName, Types.INTEGER));
+    #elseif ($columnIsEnum == "true")
+            columnValues.put(
+                    ${peerClassName}.$peerColumnName,
+                    new JdbcTypedValue(
+                        ${field}.${getter}().getValue(),
+                        ${columnSchemaType.getJdbcType()}));
     #else
             columnValues.put(
                     ${peerClassName}.$peerColumnName,
@@ -179,7 +186,13 @@
         columnValues.put(
                 ${peerClassName}.$peerColumnName,
                 new JdbcTypedValue($columnFieldName, Types.INTEGER));
-    #else
+    #elseif ($columnIsEnum == "true")
+            columnValues.put(
+                    ${peerClassName}.$peerColumnName,
+                    new JdbcTypedValue(
+                        ${field}.${getter}().getValue(),
+                        ${columnSchemaType.getJdbcType()}));
+     #else
         columnValues.put(
                 ${peerClassName}.$peerColumnName,
                 new JdbcTypedValue(

Modified: 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/recordmapper/base/dbObjectFieldGetter.vm
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/recordmapper/base/dbObjectFieldGetter.vm?rev=1631308&r1=1631307&r2=1631308&view=diff
==============================================================================
--- 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/recordmapper/base/dbObjectFieldGetter.vm
 (original)
+++ 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/recordmapper/base/dbObjectFieldGetter.vm
 Mon Oct 13 07:55:38 2014
@@ -84,9 +84,17 @@
                 }
 #else
   #if ($primitive == "true" || $fieldType == "String")
+    #if ($isEnum == "true")
+                return 
${fieldType}.getByValue(resultSet.${resultSetGetter}(columnIndex));
+    #else
                 return resultSet.${resultSetGetter}(columnIndex);
+    #end
   #else
+    #if ($isEnum == "true")
+                ${fieldType} value = 
${fieldType}.getByValue(resultSet.${resultSetGetter}(columnIndex));
+    #else
                 ${fieldType} value = resultSet.${resultSetGetter}(columnIndex);
+    #end
                 if (resultSet.wasNull())
                 {
                     value = null;

Modified: 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/recordmapper/base/recordMapperBase.vm
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/recordmapper/base/recordMapperBase.vm?rev=1631308&r1=1631307&r2=1631308&view=diff
==============================================================================
--- 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/recordmapper/base/recordMapperBase.vm
 (original)
+++ 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/recordmapper/base/recordMapperBase.vm
 Mon Oct 13 07:55:38 2014
@@ -40,6 +40,13 @@ import org.apache.torque.TorqueException
 import org.apache.torque.criteria.Criteria;
 import org.apache.torque.om.mapper.RecordMapper;
 
+#foreach ($columnElement in 
$torqueGen.getSourceElement().getChildren("column"))
+  #set ($colEnumPackage = $columnElement.getAttribute("enumPackage"))
+  #set ($colEnumClassName = $columnElement.getAttribute("enumClassName"))
+  #if ($columnElement.getAttribute("isEnum") == "true" && $colEnumPackage != 
$baseRecordMapperPackage) 
+import ${colEnumPackage}.${colEnumClassName};
+  #end
+#end
 #if (${baseRecordMapperPackage} != $dbObjectPackage)
 import ${dbObjectPackage}.${dbObjectClassName};
 #end

Modified: 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/conf/control.xml
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/conf/control.xml?rev=1631308&r1=1631307&r2=1631308&view=diff
==============================================================================
--- 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/conf/control.xml
 (original)
+++ 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/conf/control.xml
 Mon Oct 13 07:55:38 2014
@@ -27,11 +27,23 @@
   <options xsi:type="propertiesOptions" path="options.properties"/>
 
   <entityReference
+      systemId="http://db.apache.org/torque/4.0/templates/database.xsd";
+      resource="../../xsd/database-4-0.xsd" />
+  <entityReference
+      systemId="http://db.apache.org/torque/4.0/templates/database-strict.xsd";
+      resource="../../xsd/database-4-0-strict.xsd" />
+  <entityReference
       
systemId="http://db.apache.org/torque/torque-4.0/documentation/orm-reference/database-4-0.xsd";
       resource="../../xsd/database-4-0.xsd" />
   <entityReference
       
systemId="http://db.apache.org/torque/torque-4.0/documentation/orm-reference/database-4-0-strict.xsd";
       resource="../../xsd/database-4-0-strict.xsd" />
+  <entityReference
+      
systemId="http://db.apache.org/torque/torque-4.1/documentation/orm-reference/database-4-1.xsd";
+      resource="../../xsd/database-4-1.xsd" />
+  <entityReference
+      
systemId="http://db.apache.org/torque/torque-4.1/documentation/orm-reference/database-4-1-strict.xsd";
+      resource="../../xsd/database-4-1-strict.xsd" />
 
   <output name="torque.sql.ddl" >
     <filenameOutlet

Modified: 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/createdb/conf/control.xml
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/createdb/conf/control.xml?rev=1631308&r1=1631307&r2=1631308&view=diff
==============================================================================
--- 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/createdb/conf/control.xml
 (original)
+++ 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/createdb/conf/control.xml
 Mon Oct 13 07:55:38 2014
@@ -27,11 +27,23 @@
   <options xsi:type="propertiesOptions" path="options.properties"/>
 
   <entityReference
+      systemId="http://db.apache.org/torque/4.0/templates/database.xsd";
+      resource="../../../xsd/database-4-0.xsd" />
+  <entityReference
+      systemId="http://db.apache.org/torque/4.0/templates/database-strict.xsd";
+      resource="../../../xsd/database-4-0-strict.xsd" />
+  <entityReference
       
systemId="http://db.apache.org/torque/torque-4.0/documentation/orm-reference/database-4-0.xsd";
       resource="../../../xsd/database-4-0.xsd" />
   <entityReference
       
systemId="http://db.apache.org/torque/torque-4.0/documentation/orm-reference/database-4-0-strict.xsd";
       resource="../../../xsd/database-4-0-strict.xsd" />
+  <entityReference
+      
systemId="http://db.apache.org/torque/torque-4.1/documentation/orm-reference/database-4-1.xsd";
+      resource="../../../xsd/database-4-1.xsd" />
+  <entityReference
+      
systemId="http://db.apache.org/torque/torque-4.1/documentation/orm-reference/database-4-1-strict.xsd";
+      resource="../../../xsd/database-4-1-strict.xsd" />
 
   <output name="torque.sql.createdb">
     <filenameOutlet

Added: 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/xsd/database-4-1-strict.xsd
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/xsd/database-4-1-strict.xsd?rev=1631308&view=auto
==============================================================================
--- 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/xsd/database-4-1-strict.xsd
 (added)
+++ 
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/xsd/database-4-1-strict.xsd
 Mon Oct 13 07:55:38 2014
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!--
+ 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.
+-->
+<!--
+    Torque XML database schema DTD
+    $Id: database-4-0-strict.xsd 1622915 2014-09-06 19:21:17Z tfischer $
+-->
+
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
+           targetNamespace="http://db.apache.org/torque/4.0/templates/database";
+           xmlns="http://db.apache.org/torque/4.0/templates/database";
+           elementFormDefault="qualified"
+           version="4.1">
+           
+  <xs:annotation>
+    <xs:documentation xml:lang="en">
+The XML schema used by version 4.1 and greater of the Apache Software
+Foundation Torque project(
+<a href="http://db.apache.org/torque";>http://db.apache.org/torque</a> )
+to model SQL database information. 
+This model restricts the available characters in java names and sql names
+as compared to the standard database.xsd
+    </xs:documentation>
+  </xs:annotation>
+  
+  <xs:redefine 
schemaLocation="http://db.apache.org/torque/torque-4.0/documentation/orm-reference/database-4-1.xsd";>
+    <xs:simpleType name="javaNameType">
+      <xs:annotation>
+        <xs:documentation xml:lang="en">
+  Java identifiers, e.g. [A-Za-z_$]A-Za-z_$0-9]*
+        </xs:documentation>
+      </xs:annotation>
+      <xs:restriction base="javaNameType">
+        <xs:pattern value="[A-Za-z_$][A-Za-z_$0-9]*" />
+      </xs:restriction>
+    </xs:simpleType>
+  
+    <xs:simpleType name="javaQualifiedNameType">
+      <xs:annotation>
+        <xs:documentation xml:lang="en">
+  Java fully qualified names (e.g. x.y.x)
+        </xs:documentation>
+      </xs:annotation>
+      <xs:restriction base="javaQualifiedNameType">
+        <xs:pattern
+                value="([A-Za-z_$][A-Za-z_$0-9]*[.])*[A-Za-z_$][A-Za-z_$0-9]*" 
/>
+      </xs:restriction>
+    </xs:simpleType>
+  
+    <xs:simpleType name="sqlNameType">
+      <xs:annotation>
+        <xs:documentation xml:lang="en">
+  SQL Standard non-delimited identifiers.
+        </xs:documentation>
+      </xs:annotation>
+      <xs:restriction base="sqlNameType">
+        <xs:pattern value="[A-Za-z$#][A-Za-z_$#0-9]*" />
+      </xs:restriction>
+    </xs:simpleType>
+
+    <xs:simpleType name="sqlQualifiedNameType">
+      <xs:annotation>
+        <xs:documentation xml:lang="en">
+  SQL Standard non-delimited identifiers.
+        </xs:documentation>
+      </xs:annotation>
+      <xs:restriction base="sqlQualifiedNameType">
+        <xs:pattern 
value="[A-Za-z$#][A-Za-z_$#0-9]*(\.[A-Za-z$#][A-Za-z_$#0-9]*)?" />
+      </xs:restriction>
+    </xs:simpleType>
+  </xs:redefine>
+
+</xs:schema>
\ No newline at end of file



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

Reply via email to