You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by tf...@apache.org on 2006/06/15 12:07:46 UTC

svn commit: r414531 [1/2] - in /db/torque: generator/trunk/src/java/org/apache/torque/engine/database/model/ runtime/trunk/src/java/org/apache/torque/map/ runtime/trunk/src/java/org/apache/torque/om/ runtime/trunk/xdocs/reference/ site/trunk/xdocs/ tem...

Author: tfischer
Date: Thu Jun 15 03:07:45 2006
New Revision: 414531

URL: http://svn.apache.org/viewvc?rev=414531&view=rev
Log:
Added patch from TORQUE-22 with minor corrections.
Thanks to Greg Monroe for the patch.

Added:
    db/torque/runtime/trunk/src/java/org/apache/torque/map/InheritanceMap.java
    db/torque/templates/trunk/src/templates/om/DatabaseMapInit.vm
    db/torque/templates/trunk/src/templates/om/DatabaseMapInitLinkageObject.vm
    db/torque/test/trunk/test-project/src/java/org/apache/torque/map/DatabaseMapTest.java
Modified:
    db/torque/generator/trunk/src/java/org/apache/torque/engine/database/model/Column.java
    db/torque/generator/trunk/src/java/org/apache/torque/engine/database/model/Database.java
    db/torque/runtime/trunk/src/java/org/apache/torque/map/ColumnMap.java
    db/torque/runtime/trunk/src/java/org/apache/torque/map/DatabaseMap.java
    db/torque/runtime/trunk/src/java/org/apache/torque/map/TableMap.java
    db/torque/runtime/trunk/src/java/org/apache/torque/om/BaseObject.java
    db/torque/runtime/trunk/xdocs/reference/initialisation-configuration.xml
    db/torque/site/trunk/xdocs/changes.xml
    db/torque/templates/trunk/src/templates/om/Control.vm
    db/torque/templates/trunk/src/templates/om/MapBuilder.vm
    db/torque/templates/trunk/src/templates/om/Object.vm
    db/torque/templates/trunk/src/templates/om/ObjectWithManager.vm
    db/torque/templates/trunk/src/templates/om/Peer.vm
    db/torque/test/trunk/test-project/src/schema/test-schema.xml

Modified: db/torque/generator/trunk/src/java/org/apache/torque/engine/database/model/Column.java
URL: http://svn.apache.org/viewvc/db/torque/generator/trunk/src/java/org/apache/torque/engine/database/model/Column.java?rev=414531&r1=414530&r2=414531&view=diff
==============================================================================
--- db/torque/generator/trunk/src/java/org/apache/torque/engine/database/model/Column.java (original)
+++ db/torque/generator/trunk/src/java/org/apache/torque/engine/database/model/Column.java Thu Jun 15 03:07:45 2006
@@ -1169,4 +1169,14 @@
     {
         this.correctGetters = correctGetters;
     }
+
+    /**
+     * Get the value of the inheritance attribute defined in the schema XML.
+     * 
+     * @return Returns the inheritanceType.
+     */
+    public String getInheritanceType()
+    {
+        return inheritanceType;
+    }
 }

Modified: db/torque/generator/trunk/src/java/org/apache/torque/engine/database/model/Database.java
URL: http://svn.apache.org/viewvc/db/torque/generator/trunk/src/java/org/apache/torque/engine/database/model/Database.java?rev=414531&r1=414530&r2=414531&view=diff
==============================================================================
--- db/torque/generator/trunk/src/java/org/apache/torque/engine/database/model/Database.java (original)
+++ db/torque/generator/trunk/src/java/org/apache/torque/engine/database/model/Database.java Thu Jun 15 03:07:45 2006
@@ -23,6 +23,8 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.torque.engine.EngineException;
 import org.apache.torque.engine.database.transform.DTDResolver;
 import org.apache.torque.engine.platform.Platform;
@@ -42,10 +44,14 @@
  */
 public class Database
 {
+    /** Logging class from commons.logging */
+    private static Log log = LogFactory.getLog(Database.class);
+
     private String databaseType = null;
     private List tableList = new ArrayList(100);
     private Map domainMap = new HashMap();
     private String name;
+    private String javaName;
     private String pkg;
     private String baseClass;
     private String basePeer;
@@ -470,6 +476,59 @@
         }
     }
 
+    /**
+     * Get the base name to use when creating related Java Classes.
+     * 
+     * @return A Java syntax capatible version of the dbName using the method
+     *         defined by the defaultJavaNamingMethod XML value.
+     */
+    public String getJavaName()
+    {
+        if (javaName == null)
+        {
+            List inputs = new ArrayList(2);
+            inputs.add(name);
+            inputs.add(defaultJavaNamingMethod);
+            try
+            {
+                javaName = NameFactory.generateName(NameFactory.JAVA_GENERATOR,
+                                                    inputs);
+            }
+            catch (EngineException e)
+            {
+                log.error(e, e);
+            }
+        }
+        return javaName;
+    }
+    
+    /**
+     * Convert dbName to a Java compatible name by the JavaName method only 
+     * (ignores the defaultJavaNamingMethod).
+     * 
+     * @return The current dbName converted to a standard format that can
+     *          be used as part of a Java Object name.
+     */
+    public String getStandardJavaName()
+    {
+        if (javaName == null)
+        {
+            List inputs = new ArrayList(2);
+            inputs.add(name);
+            inputs.add(NameGenerator.CONV_METHOD_JAVANAME);
+            try
+            {
+                javaName = NameFactory.generateName(NameFactory.JAVA_GENERATOR,
+                                                    inputs);
+            }
+            catch (EngineException e)
+            {
+                log.error(e, e);
+            }
+        }
+        return javaName;
+    }
+    
     /**
      * Creats a string representation of this Database.
      * The representation is given in xml format.

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/map/ColumnMap.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/map/ColumnMap.java?rev=414531&r1=414530&r2=414531&view=diff
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/map/ColumnMap.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/map/ColumnMap.java Thu Jun 15 03:07:45 2006
@@ -1,7 +1,7 @@
 package org.apache.torque.map;
 
 /*
- * Copyright 2001-2005 The Apache Software Foundation.
+ * Copyright 2001-2006 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License")
  * you may not use this file except in compliance with the License.
@@ -16,10 +16,21 @@
  * limitations under the License.
  */
 
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.commons.collections.map.ListOrderedMap;
+
 /**
  * ColumnMap is used to model a column of a table in a database.
- *
+ * <p>
+ * Note that this information should be set via the <Table>MapBuilder class and
+ * not changed by applications. The set methods are only public because this
+ * class needs them.
+ * 
  * @author <a href="mailto:jmcnally@collab.net">John D. McNally</a>
+ * @author <a href="mailto:greg.monroe@dukece.com">Greg Monroe</a>
  * @version $Id$
  */
 public class ColumnMap implements java.io.Serializable
@@ -30,16 +41,19 @@
     /** Type of the column. */
     private Object type = null;
 
+    /** Should object type be converted to primitive. */
+    private boolean usePrimitive = true;
+
     /** Size of the column. */
     private int size = 0;
-    
+
     /** Scale of the column */
     private int scale = 0;
 
     /** Is it a primary key? */
     private boolean pk = false;
 
-    /** Is null value allowed ?*/
+    /** Is null value allowed ? */
     private boolean notNull = false;
 
     /** Name of the table that this column is related to. */
@@ -54,22 +68,84 @@
     /** The name of the column. */
     private String columnName;
 
+    /**
+     * The Java Name of this column as defined in XML or created by the
+     * generator code.
+     */
+    private String javaName;
+
+    /** Is this column an autoincrement column ? */
+    private boolean autoIncrement = false;
+
+    /** Column description info (if any). */
+    private String description = "";
+
+    /** is Column protected ? */
+    private boolean isProtected = false;
+
+    /**
+     * String representing the default value defined for field. Note that
+     * default is a keyword, so defaultValue is used to store the value for the
+     * get/setDefault() methods.
+     */
+    private String defaultValue = null;
+
+    /** Inheritance type used. */
+    private String inheritance = "false";
+
+    /**
+     * Does column uses Inheritance subclasses? Note that this is tied to the
+     * TableMap useInheritance thru the set function.
+     */
+    private boolean useInheritance;
+
+    /** Associated of inheritance maps. */
+    private Map inheritanceMaps = Collections
+            .synchronizedMap(new ListOrderedMap());
+
+    /** Input validator class name. (in DTD but not used?) */
+    private String inputValidator;
+
+    /** Java naming method the generator used. */
+    private String javaNamingMethod;
+
+    /** Java type string specified in XML. */
+    private String javaType;
+
+    /** Column position in the table (one based). */
+    private int position = -1;
 
     /**
      * Constructor.
-     *
+     * 
      * @param name The name of the column.
      * @param containingTable TableMap of the table this column is in.
      */
     public ColumnMap(String name, TableMap containingTable)
     {
-        this.columnName = name;
         table = containingTable;
+        this.columnName = normalizeName(name);
+    }
+
+    /**
+     * Makes sure that the column names don't include table prefixes. E.g.,
+     * SCARAB_PROJECT.PROJECT_ID should be PROJECT_ID.
+     * 
+     * @param name The name to check
+     * @return The corrected name if needed or the same name if not.
+     */
+    protected String normalizeName(String name)
+    {
+        if (name.indexOf('.') > 0)
+        {
+            return name.substring(name.lastIndexOf('.') + 1);
+        }
+        return name;
     }
 
     /**
      * Get the name of a column.
-     *
+     * 
      * @return A String with the column name.
      */
     public String getColumnName()
@@ -79,7 +155,7 @@
 
     /**
      * Get the table name + column name.
-     *
+     * 
      * @return A String with the full column name.
      */
     public String getFullyQualifiedName()
@@ -89,7 +165,7 @@
 
     /**
      * Get the name of the table this column is in.
-     *
+     * 
      * @return A String with the table name.
      */
     public String getTableName()
@@ -99,17 +175,17 @@
 
     /**
      * Set the type of this column.
-     *
+     * 
      * @param type An Object specifying the type.
      */
-    public void setType (Object type)
+    public void setType(Object type)
     {
         this.type = type;
     }
 
     /**
      * Set the size of this column.
-     *
+     * 
      * @param size An int specifying the size.
      */
     public void setSize(int size)
@@ -119,7 +195,7 @@
 
     /**
      * Set if this column is a primary key or not.
-     *
+     * 
      * @param pk True if column is a primary key.
      */
     public void setPrimaryKey(boolean pk)
@@ -129,7 +205,7 @@
 
     /**
      * Set if this column may be null.
-     *
+     * 
      * @param nn True if column may be null.
      */
     public void setNotNull(boolean nn)
@@ -139,7 +215,7 @@
 
     /**
      * Set the foreign key for this column.
-     *
+     * 
      * @param fullyQualifiedName The name of the table.column that is
      * foreign.
      */
@@ -161,7 +237,7 @@
 
     /**
      * Set the foreign key for this column.
-     *
+     * 
      * @param tableName The name of the table that is foreign.
      * @param columnName The name of the column that is foreign.
      */
@@ -171,7 +247,7 @@
                 && columnName.length() > 0)
         {
             relatedTableName = tableName;
-            relatedColumnName = columnName;
+            relatedColumnName = normalizeName(columnName);
         }
         else
         {
@@ -181,8 +257,9 @@
     }
 
     /**
-     * Get the type of this column.
-     *
+     * Get the type of this column. Note that if usePrimitive is true, this may
+     * need to be converted.
+     * 
      * @return An Object specifying the type.
      */
     public Object getType()
@@ -191,15 +268,16 @@
     }
 
     /**
-     * The "precision" value from the XML 
+     * The "precision" value from the XML
      * size="&lt;precision&gt;[,&lt;scale&gt;]"
      * attribute. Where [,&lt;scale&gt;] is optional. 
      * 
-     * If the size attribute has not been set in the XML, it will return 0.<p>
+     * If the size attribute has not been set in the XML, it will return 0.
+     * <p>
+     * 
+     * Note that the size="P,S" format should be replaced with size="P"
+     * scale="S".
      * 
-     * Note that the size="P,S" format should be replaced with 
-     * size="P" scale="S".
-     *
      * @return An int specifying the size.
      */
     public int getSize()
@@ -209,7 +287,7 @@
 
     /**
      * Is this column a primary key?
-     *
+     * 
      * @return True if column is a primary key.
      */
     public boolean isPrimaryKey()
@@ -219,7 +297,7 @@
 
     /**
      * Is null value allowed ?
-     *
+     * 
      * @return True if column may be null.
      */
     public boolean isNotNull()
@@ -229,7 +307,7 @@
 
     /**
      * Is this column a foreign key?
-     *
+     * 
      * @return True if column is a foreign key.
      */
     public boolean isForeignKey()
@@ -239,7 +317,7 @@
 
     /**
      * Get the table.column that this column is related to.
-     *
+     * 
      * @return A String with the full name for the related column.
      */
     public String getRelatedName()
@@ -249,7 +327,7 @@
 
     /**
      * Get the table name that this column is related to.
-     *
+     * 
      * @return A String with the name for the related table.
      */
     public String getRelatedTableName()
@@ -259,7 +337,7 @@
 
     /**
      * Get the column name that this column is related to.
-     *
+     * 
      * @return A String with the name for the related column.
      */
     public String getRelatedColumnName()
@@ -269,13 +347,13 @@
 
     /**
      * Gets the scale set for this column (if any) as set in the XML database
-     * definition.  E.g., the value of the scale attribute or the scale portion
-     * of a size="P,S" attribute. 
-     * (Note: size="P,S" format is being deprecated!).
-     *
+     * definition. E.g., the value of the scale attribute or the scale portion
+     * of a size="P,S" attribute. (Note: size="P,S" format is being
+     * deprecated!).
+     * 
      * @return Returns the scale.
      */
-    public int getScale() 
+    public int getScale()
     {
         return scale;
     }
@@ -283,8 +361,330 @@
     /**
      * @param scale The scale to set.
      */
-    public void setScale(int scale) 
+    public void setScale(int scale)
     {
         this.scale = scale;
     }
-}
+
+    /**
+     * Gets the Java Name for this column as defined in XML or created by
+     * generator code.
+     * 
+     * @return the Java Name.
+     */
+    public String getJavaName()
+    {
+        return this.javaName;
+    }
+
+    /**
+     * Sets the Java Name for this column.
+     * 
+     * @return the Java Name.
+     */
+    public void setJavaName(String name)
+    {
+        this.javaName = name;
+    }
+
+    /**
+     * Returns whether this column is an autoincrement column.
+     * 
+     * @return true if this column is an autoIncrement column, false otherwise.
+     */
+    public boolean isAutoIncrement()
+    {
+        return autoIncrement;
+    }
+
+    /**
+     * Sets whether this column is an autoincrement column.
+     * 
+     * @param autoIncrement whether this colimn is an autoincrement column.
+     */
+    public void setAutoIncrement(boolean autoIncrement)
+    {
+        this.autoIncrement = autoIncrement;
+    }
+
+    /**
+     * A string representing the default value defined for this column.
+     * 
+     * @return The default value of this column, if any.
+     */
+    public String getDefault()
+    {
+        return defaultValue;
+    }
+
+    /**
+     * Sets the default value for this column.
+     * 
+     * @param defaultValue The defaultValue to set.
+     */
+    public void setDefault(String defaultValue)
+    {
+        this.defaultValue = defaultValue;
+    }
+
+    /**
+     * Returns the column description info.
+     * 
+     * @return the description, if any.
+     */
+    public String getDescription()
+    {
+        return description;
+    }
+
+    /**
+     * Sets the description for this column.
+     * 
+     * @param description The description to set.
+     */
+    public void setDescription(String description)
+    {
+        this.description = description;
+    }
+
+    /**
+     * Get the inheritance information associated with this column,
+     * 
+     * @return Returns an array of associated inheritanceMap. 
+     *         The array is in XML order.
+     */
+    public InheritanceMap[] getInheritanceMaps()
+    {
+        InheritanceMap[] iMaps = new InheritanceMap[inheritanceMaps.size()];
+        synchronized (inheritanceMaps)
+        {
+            Iterator it = inheritanceMaps.values().iterator();
+            int i = 0;
+            while (it.hasNext())
+            {
+                iMaps[i++] = (InheritanceMap) it.next();
+            }
+        }
+        return iMaps;
+    }
+
+    /**
+     * Add an associated inheritance mapping.
+     * 
+     * @param map The inheritanceMap to associate with this column.
+     */
+    public void addInheritanceMap(InheritanceMap map)
+    {
+        setUseInheritance(true);
+        this.inheritanceMaps.put(map.getKey(), map);
+    }
+
+    /**
+     * Gets the inheritance type used.
+     * 
+     * @return the inheritance type used.
+     */
+    public String getInheritance()
+    {
+        return inheritance;
+    }
+
+    /**
+     * Sets the inheritance type.
+     * 
+     * @param inheritance The inheritance type to set.
+     */
+    public void setInheritance(String inheritanceType)
+    {
+        this.inheritance = inheritanceType;
+    }
+
+    /**
+     * Returns the input validator class name. 
+     * (This property is in the DTD, but currently not used by Torque?)
+     * 
+     * @return Returns the inputValidator.
+     */
+    public String getInputValidator()
+    {
+        return inputValidator;
+    }
+
+    /**
+     * Sets the input validator class name.
+     * 
+     * @param inputValidator The inputValidator to set.
+     */
+    public void setInputValidator(String inputValidator)
+    {
+        this.inputValidator = inputValidator;
+    }
+
+    /**
+     * Returns whether getters and setters are generated with the 
+     * access modifier "protected" rather than "public".
+     * 
+     * @return whether the accessors should be protected rather than public.
+     */
+    public boolean isProtected()
+    {
+        return isProtected;
+    }
+
+    /**
+     * Sets whether getters and setters should be generated with the 
+     * access modifier "protected" rather than "public".
+     * 
+     * @param isProtected whether getters and setters for this column
+     *        are protected.
+     */
+    public void setProtected(boolean isProtected)
+    {
+        this.isProtected = isProtected;
+    }
+
+    /**
+     * Returns whether this column is a primary key.
+     * 
+     * @return whether this column is a primary key.
+     */
+    public boolean isPk()
+    {
+        return pk;
+    }
+
+    /**
+     * Sets whether this column is a primary key.
+     * 
+     * @param pk whether this column is a primary key.
+     */
+    public void setPk(boolean pk)
+    {
+        this.pk = pk;
+    }
+
+    /**
+     * Returns whether this column uses inheritance subclasses.
+     * 
+     * @return true if inheritance subclasses are used, false otherwise.
+     */
+    public boolean isUseInheritance()
+    {
+        return useInheritance;
+    }
+
+    /**
+     * Sets whether this column uses inheritance subclasses.
+     * 
+     * @param useInheritance whether this column uses Inheritance subclasses.
+     */
+    public void setUseInheritance(boolean useInheritance)
+    {
+        this.useInheritance = useInheritance;
+    }
+
+    /**
+     * Get the inheritance map with the specified key.
+     * 
+     * @param key the key of the inheritance map.
+     * @return the inheritance map with the specified key, or null if no 
+     *         inheritance map with the specified key exists in this column. 
+     */
+    public InheritanceMap getInheritanceMap(String key)
+    {
+        return (InheritanceMap) inheritanceMaps.get(key);
+    }
+
+    /**
+     * Returns whether this colum uses primitive values rather than objects.
+     * 
+     * @return true if this colum uses primitive values, false if it uses
+     *         objects.
+     */
+    public boolean isUsePrimitive()
+    {
+        return usePrimitive;
+    }
+
+    /**
+     * Sets whether this colum uses primitive values rather than objects.
+     * 
+     * @param usePrimitive whether primitive objects are used 
+     *        rather than objects.
+     */
+    public void setUsePrimitive(boolean usePrimitive)
+    {
+        this.usePrimitive = usePrimitive;
+    }
+
+    /**
+     * Returns the Java naming method for this column.
+     * 
+     * @return the javaNamingMethod for this column.
+     */
+    public String getJavaNamingMethod()
+    {
+        return javaNamingMethod;
+    }
+
+    /**
+     * Sets the java naming method for this column.
+     * 
+     * @param javaNamingMethod The javaNamingMethod to set.
+     */
+    public void setJavaNamingMethod(String javaNamingMethod)
+    {
+        this.javaNamingMethod = javaNamingMethod;
+    }
+
+    /**
+     * Returns the map for the table this column belongs to.
+     * 
+     * @return the table map for this column.
+     */
+    public TableMap getTable()
+    {
+        return table;
+    }
+
+    /**
+     * Returns the position (one based) of this column in the table. 
+     * XML order is preserved.
+     * 
+     * @return The position of this column, one-based.
+     */
+    public int getPosition()
+    {
+        return position;
+    }
+
+    /**
+     * Sets the position (one based) of this column in the table.
+     * 
+     * @param position The position to set.
+     */
+    public void setPosition(int position)
+    {
+        this.position = position;
+    }
+
+    /**
+     * Returns the java type of this column.
+     * 
+     * @return the javaType.
+     */
+    public String getJavaType()
+    {
+        return javaType;
+    }
+
+    /**
+     * Sets the java type of this column.
+     * 
+     * @param javaType The javaType to set.
+     */
+    public void setJavaType(String javaType)
+    {
+        this.javaType = javaType;
+    }
+}
\ No newline at end of file

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/map/DatabaseMap.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/map/DatabaseMap.java?rev=414531&r1=414530&r2=414531&view=diff
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/map/DatabaseMap.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/map/DatabaseMap.java Thu Jun 15 03:07:45 2006
@@ -16,11 +16,17 @@
  * limitations under the License.
  */
 
+import java.lang.reflect.Method;
+import java.text.MessageFormat;
+import java.util.Collections;
 import java.util.HashMap;
-import java.util.Hashtable;
 import java.util.Iterator;
+import java.util.Map;
+import java.util.StringTokenizer;
 
-import org.apache.torque.Database;
+import org.apache.commons.collections.map.ListOrderedMap;
+import org.apache.commons.lang.StringUtils;
+import org.apache.torque.TorqueException;
 import org.apache.torque.adapter.IDMethod;
 import org.apache.torque.oid.IDBroker;
 import org.apache.torque.oid.IdGenerator;
@@ -30,10 +36,43 @@
  *
  * @author <a href="mailto:jmcnally@collab.net">John D. McNally</a>
  * @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
+ * @author <a href="mailto:greg.monroe@dukece.com">Greg Monroe</a>
  * @version $Id$
  */
 public class DatabaseMap implements java.io.Serializable
 {
+    /**
+     * The character used by most implementations as the separator
+     * between name elements.
+     */
+    char STD_SEPARATOR_CHAR = '_';
+
+    /**
+     * The character which separates the schema name from the table name
+     */
+    char SCHEMA_SEPARATOR_CHAR = '.';
+    
+    /** 
+     * Format used to create create the class name for initializing a DB 
+     * specific map 
+     */
+    public static final String INIT_CLASS_NAME_FORMAT = 
+                                "org.apache.torque.linkage.{0}MapInit";
+    
+    public static String[] eMsgs = { 
+        "Invalid Torque OM setup for Database \"{0}\".\n"+
+            "Database Map initialization class, \"{1}\","+" " +
+            "could not be found in your classpath.",
+        "Invalid Torque OM setup for Database \"{0}\".\n"+
+            "A class that the Database Map initialization class, \"{1}\", "+
+            "depends on could not be found.",
+        "Invalid Torque OM setup for Database \"{0}\".\n"+
+            "Something unexpected happened doing Class.forName(\"{1}\").  "+
+            "See the nested exception for details.",
+        "Invalid Torque OM setup for Database \"{0}\".\n"+
+            "An error occured invoking the init() method in class, \"{1}\""
+    };
+    
     /** The serialVersionUID for this class. */
     private static final long serialVersionUID = 955251837095032274L;
 
@@ -41,7 +80,7 @@
     private String name;
 
     /** Name of the tables in the database. */
-    private Hashtable tables;
+    private Map tables;
 
     /**
      * A special table used to generate primary keys for the other
@@ -54,13 +93,16 @@
 
     /** The IdGenerators, keyed by type of idMethod. */
     private HashMap idGenerators;
+    
+    /** Flag indicating that all tables have been loaded via initialize() */
+    boolean isInitialized = false;
 
     /**
      * Constructs a new DatabaseMap.
      */
     public DatabaseMap()
     {
-        tables = new Hashtable();
+        tables = Collections.synchronizedMap(new ListOrderedMap());
         idGenerators = new HashMap(6);
     }
 
@@ -75,7 +117,7 @@
     public DatabaseMap(String name, int numberOfTables)
     {
         this.name = name;
-        tables = new Hashtable((int) (1.25 * numberOfTables) + 1);
+        tables = Collections.synchronizedMap(new ListOrderedMap());
         idGenerators = new HashMap(6);
     }
 
@@ -89,7 +131,7 @@
     public DatabaseMap(String name)
     {
         this.name = name;
-        tables = new Hashtable();
+        tables = Collections.synchronizedMap(new ListOrderedMap());
         idGenerators = new HashMap(6);
     }
 
@@ -155,7 +197,12 @@
     }
 
     /**
-     * Get a TableMap for the table by name.
+     * Get a TableMap for the table by name. <p>
+     *
+     * Note that by default Torque uses lazy initialization to minimize
+     * memory usage and startup time.  However, if an OM or PEER class 
+     * has not called the table's MapBuilder class, it will not be here. 
+     * See the optional initialize method if you need full OM Mapping.<p>
      *
      * @param name Name of the table.
      * @return A TableMap, null if the table was not found.
@@ -166,18 +213,26 @@
     }
 
     /**
-     * Get a TableMap[] of all of the tables in the database.
+     * Get a TableMap[] of all of the tables in the database.<P>
+     * 
+     * Note that by default Torque uses lazy initialization to minimize
+     * memory usage and startup time.  However, if an OM or PEER class 
+     * has not called the table's MapBuilder class, it will not be here. 
+     * See the optional initialize method if you need full OM Mapping.<p>
      *
      * @return A TableMap[].
      */
     public TableMap[] getTables()
     {
         TableMap[] dbTables = new TableMap[tables.size()];
-        Iterator it = tables.values().iterator();
-        int i = 0;
-        while (it.hasNext())
+        synchronized (tables)
         {
-            dbTables[i++] = (TableMap) it.next() ;
+            Iterator it = tables.values().iterator();
+            int i = 0;
+            while (it.hasNext())
+            {
+                dbTables[i++] = (TableMap) it.next() ;
+            }
         }
         return dbTables;
     }
@@ -290,4 +345,119 @@
         }
         return false;
     }
-}
+    
+    /**
+     * Fully populate this DatabaseMap with all the TablesMaps.  This
+     * is only needed if the application needs to use the complete OM
+     * mapping information.  Otherwise, the OM Mapping information
+     * will be populated as needed by OM and Peer classes.  An example
+     * of how to initialize the map info from the application:<p>
+     * 
+     *   <code>
+     *   DatabaseMap dbMap = Torque.getDatabaseMap( dbName );
+     *   try {
+     *      dbMap.initialize();
+     *   } catch ( TorqueException e ) {
+     *      ... error handling
+     *   }
+     *   </code>
+     * 
+     * Note that Torque database names are case sensitive and this DB 
+     * map must be retrieved with the exact name used in the XML schema.<p>
+     * 
+     * This uses Java reflection methods to locate and run the 
+     * init() method of a class generated in the org.apache.torque.linkage
+     * package with a name based on the XML Database name value, e.g.
+     * org.apache.torque.linkage.DefaultMapInit<p>  
+     * 
+     * Some misconfiguration situations that could cause this method to fail
+     * are:<p>
+     * 
+     * It was used with a Torque OM set of classes generated by V3.2 or older;
+     * <br>
+     * The class(es) in the org.apache.torque.linkage package were not included 
+     * with the other generated class files (e.g. the jar file creation process
+     * only included com.* and not org.* files).<p>
+     * 
+     * @throws TorqueException If an error is encountered locating and calling 
+     *                          the init method.
+     */
+    public synchronized void initialize() throws TorqueException
+    {
+        if (isInitialized) 
+        {
+            return;
+        }        
+        String initClassName = MessageFormat.format(INIT_CLASS_NAME_FORMAT, 
+                new Object[] { javanameMethod(getName()) });
+        
+        Class initClass = null;
+        try 
+        {
+            initClass = Class.forName(initClassName);
+        }
+        catch (ClassNotFoundException e)
+        {
+            throw new TorqueException(MessageFormat.format(eMsgs[0], 
+                    new Object[] { getName(), initClassName }), e);
+        }
+        catch (LinkageError e)
+        {
+            throw new TorqueException(MessageFormat.format(eMsgs[1], 
+                    new Object[] { getName(), initClassName }), e);
+        }
+        catch (Throwable e)
+        {
+            throw new TorqueException(MessageFormat.format(eMsgs[2], 
+                    new Object[] { getName(), initClassName }), e);
+        }
+        try
+        {
+            Method initMethod = initClass.getMethod("init", null);
+            initMethod.invoke(null, null);
+        }
+        catch (Exception e)
+        {
+            throw new TorqueException(MessageFormat.format(eMsgs[3], 
+                    new Object[] { getName(), initClassName }), e);
+        }
+        isInitialized = true;
+    }
+    
+    /**
+     * Converts a database schema name to java object name.  Operates
+     * same as underscoreMethod but does not convert anything to
+     * lowercase.  This must match the javaNameMethod in the 
+     * JavaNameGenerator class in Generator code. 
+     *
+     * @param schemaName name to be converted.
+     * @return converted name.
+     * 
+     * @see org.apache.torque.engine.database.model.NameGenerator
+     */
+    protected String javanameMethod(String schemaName)
+    {
+        StringBuffer name = new StringBuffer();
+        StringTokenizer tok = new StringTokenizer
+            (schemaName, String.valueOf(STD_SEPARATOR_CHAR));
+        while (tok.hasMoreTokens())
+        {
+            String namePart = (String) tok.nextElement();
+            name.append(StringUtils.capitalize(namePart));
+        }
+
+        // remove the SCHEMA_SEPARATOR_CHARs and capitalize
+        // the tokens
+        schemaName = name.toString();
+        name = new StringBuffer();
+
+        tok = new StringTokenizer
+            (schemaName, String.valueOf(SCHEMA_SEPARATOR_CHAR));
+        while (tok.hasMoreTokens())
+        {
+            String namePart = (String) tok.nextElement();
+            name.append(StringUtils.capitalize(namePart));
+        }
+        return name.toString();
+    }
+}
\ No newline at end of file

Added: db/torque/runtime/trunk/src/java/org/apache/torque/map/InheritanceMap.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/map/InheritanceMap.java?rev=414531&view=auto
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/map/InheritanceMap.java (added)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/map/InheritanceMap.java Thu Jun 15 03:07:45 2006
@@ -0,0 +1,146 @@
+package org.apache.torque.map;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+/**
+ * InheritanceMap is used to model OM inheritance classes.
+ * 
+ * @author <a href="mailto:greg.monroe@dukece.com">Greg Monroe</a>
+ * @version $Id$
+ */
+public class InheritanceMap
+{
+    /** 
+     * The value in the related column that is associated with 
+     * this information. 
+     */
+    private String key;
+
+    /**
+     * The name of the class which impliments this inheritance mode.
+     */
+    private String className;
+
+    /** 
+     * The name of class which class name extends. 
+     * Retrieved via getExtends().
+     */
+    private String ancestor;
+
+    /** The column this info is related to. */
+    private ColumnMap column;
+
+    /**
+     * Create an inheritance map object.
+     * 
+     * @param column The column this inheritance map belongs to.
+     * @param key Key to determine which subclass applies
+     * @param className package.Name of sub class to use for record.
+     * @param ancestor package.Name of class that className extends.
+     */
+    public InheritanceMap(ColumnMap column, String key, String className,
+            String ancestor)
+    {
+        setColumn(column);
+        setKey(key);
+        setClassName(className);
+        setExtends(ancestor);
+    }
+
+    /**
+     * Returns the ancestor class for the class described by this
+     * InheritanceMap.
+     * 
+     * @return the ancestor class for the class described by this
+     *         InheritanceMap.
+     */
+    public String getExtends()
+    {
+        return ancestor;
+    }
+
+    /**
+     * Sets the ancestor class for the class described by this InheritanceMap.
+     * 
+     * @param ancestor The ancestor for the class described by this 
+     *        InheritanceMap.
+     */
+    public void setExtends(String ancestor)
+    {
+        this.ancestor = ancestor;
+    }
+
+    /**
+     * Returns the class name for this InheritanceMap.
+     * 
+     * @return The class name for this InheritanceMap.
+     */
+    public String getClassName()
+    {
+        return className;
+    }
+
+    /**
+     * Sets the class name for this InheritanceMap.
+     * 
+     * @param className The className for this InheritanceMap.
+     */
+    public void setClassName(String className)
+    {
+        this.className = className;
+    }
+
+    /**
+     * Returns the column this inheritance map belongs to.
+     * 
+     * @return the column this inheritance map belongs to.
+     */
+    public ColumnMap getColumn()
+    {
+        return column;
+    }
+
+    /**
+     * Sets the column this inheritance map belongs to.
+     * 
+     * @param column the column this inheritance map belongs to.
+     */
+    public void setColumn(ColumnMap column)
+    {
+        this.column = column;
+    }
+
+    /**
+     * Returns the key by which this inheritanceMap is activated.
+     * 
+     * @return The key by which this inheritanceMap is activated.
+     */
+    public String getKey()
+    {
+        return key;
+    }
+
+    /**
+     * Sets the key by which this inheritanceMap is activated.
+     * 
+     * @param key The key by which this inheritanceMap is activated.
+     */
+    public void setKey(String key)
+    {
+        this.key = key;
+    }
+}
\ No newline at end of file

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/map/TableMap.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/map/TableMap.java?rev=414531&r1=414530&r2=414531&view=diff
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/map/TableMap.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/map/TableMap.java Thu Jun 15 03:07:45 2006
@@ -1,7 +1,7 @@
 package org.apache.torque.map;
 
 /*
- * Copyright 2001-2005 The Apache Software Foundation.
+ * Copyright 2001-2006 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License")
  * you may not use this file except in compliance with the License.
@@ -16,12 +16,13 @@
  * limitations under the License.
  */
 
+import java.util.Collections;
 import java.util.Iterator;
-import java.util.Hashtable;
+import java.util.Map;
 import java.util.StringTokenizer;
 
+import org.apache.commons.collections.map.ListOrderedMap;
 import org.apache.commons.lang.StringUtils;
-
 import org.apache.torque.adapter.IDMethod;
 import org.apache.torque.oid.IdGenerator;
 
@@ -30,6 +31,7 @@
  *
  * @author <a href="mailto:jmcnally@collab.net">John D. McNally</a>
  * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
+ * @author <a href="mailto:greg.monroe@dukece.com">Greg Monroe</a>
  * @version $Id$
  */
 public class TableMap implements IDMethod, java.io.Serializable
@@ -40,11 +42,11 @@
     /** The list of valid ID generation methods. */
     protected static final String[] VALID_ID_METHODS =
     {
-        NATIVE, AUTO_INCREMENT, SEQUENCE, ID_BROKER, NO_ID_METHOD
+            NATIVE, AUTO_INCREMENT, SEQUENCE, ID_BROKER, NO_ID_METHOD
     };
 
-    /** The columns in the table. */
-    private Hashtable columns;
+    /** The columns in the table. XML Order is preserved. */
+    private Map columns;
 
     /** The database this table belongs to. */
     private DatabaseMap dbMap;
@@ -52,12 +54,33 @@
     /** The name of the table. */
     private String tableName;
 
+    /** The JavaName of the table as defined in XML */
+    private String javaName;
+
     /** The prefix on the table name. */
     private String prefix;
 
     /** The primary key generation method. */
     private String primaryKeyMethod = NO_ID_METHOD;
 
+    /** The table description info. */
+    private String description = "";
+
+    /** The Peer Class for this table. */
+    private Class peerClass;
+
+    /** The OM Root Class for this table. */
+    private Class omClass;
+
+    /** Whether any column uses Inheritance. */
+    private boolean useInheritance = false;
+
+    /** Whether cache managers are used. */
+    private boolean useManager = false;
+
+    /** The associated cache manager class. */
+    private Class managerClass;
+
     /**
      * Object to store information that is needed if the
      * for generating primary keys.
@@ -84,7 +107,7 @@
     {
         this.tableName = tableName;
         dbMap = containingDB;
-        columns = new Hashtable((int) (1.25 * numberOfColumns) + 1);
+        columns = Collections.synchronizedMap(new ListOrderedMap());
     }
 
     /**
@@ -97,7 +120,7 @@
     {
         this.tableName = tableName;
         dbMap = containingDB;
-        columns = new Hashtable(20);
+        columns = Collections.synchronizedMap(new ListOrderedMap());
     }
 
     /**
@@ -109,13 +132,13 @@
      * @param containingDB A DatabaseMap that this table belongs to.
      */
     public TableMap(String tableName,
-                    String prefix,
+                    String prefix, 
                     DatabaseMap containingDB)
     {
         this.tableName = tableName;
         this.prefix = prefix;
         dbMap = containingDB;
-        columns = new Hashtable(20);
+        columns = Collections.synchronizedMap(new ListOrderedMap());
     }
 
     /**
@@ -163,14 +186,17 @@
      */
     public boolean containsObjectColumn()
     {
-        Iterator it = columns.values().iterator();
-        while (it.hasNext())
+        synchronized (columns)
         {
-            Object theType = ((ColumnMap) it.next()).getType();
+            Iterator it = columns.values().iterator();
+            while (it.hasNext())
+            {
+                Object theType = ((ColumnMap) it.next()).getType();
             if (!(theType instanceof String || theType instanceof Number
                     || theType instanceof java.util.Date))
-            {
-                return true;
+                {
+                    return true;
+                }
             }
         }
         return false;
@@ -187,6 +213,26 @@
     }
 
     /**
+     * Get the Java name of the table as defined in XML.
+     *
+     * @return A String with the Java name of the table.
+     */
+    public String getJavaName()
+    {
+        return javaName;
+    }
+
+    /**
+     * Set the Java name of the table as defined by generator/XML.
+     *
+     * @param value A String with the Java name of the table.
+     */
+    public void setJavaName(String value)
+    {
+        this.javaName = value;
+    }
+
+    /**
      * Get table prefix name.
      *
      * @return A String with the prefix.
@@ -246,11 +292,14 @@
     public ColumnMap[] getColumns()
     {
         ColumnMap[] tableColumns = new ColumnMap[columns.size()];
-        Iterator it = columns.values().iterator();
-        int i = 0;
-        while (it.hasNext())
+        synchronized (columns)
         {
-            tableColumns[i++] = (ColumnMap) it.next();
+            Iterator it = columns.values().iterator();
+            int i = 0;
+            while (it.hasNext())
+            {
+                tableColumns[i++] = (ColumnMap) it.next();
+            }
         }
         return tableColumns;
     }
@@ -279,9 +328,9 @@
      *
      * @param cmap A ColumnMap.
      */
-    public void addColumn (ColumnMap cmap)
+    public void addColumn(ColumnMap cmap)
     {
-        columns.put (cmap.getColumnName(), cmap);
+        columns.put(cmap.getColumnName(), cmap);
     }
 
     /**
@@ -289,6 +338,9 @@
      *
      * @param columnName A String with the column name.
      * @param type An Object specifying the type.
+     * @deprecated Associated Column maps should be populated using it's 
+     *             set methods, then added to table via addColumn(ColumnMap).
+     *             This method will be removed in a future version of Torque.
      */
     public void addColumn(String columnName, Object type)
     {
@@ -302,18 +354,24 @@
      * @param type An Object specifying the type.
      * @param size An int specifying the size.
      * @param scale An int specifying the scale.
+     * @deprecated Associated Column maps should be populated using it's set 
+     *             methods, then added to table via addColumn(ColumnMap).
+     *             This method will be removed in a future version of Torque.
      */
     public void addColumn(String columnName, Object type, int size, int scale)
     {
         addColumn(columnName, type, false, null, null, size, scale);
     }
-    
+
     /**
      * Add a column to this table of a certain type and size.
      *
      * @param columnName A String with the column name.
      * @param type An Object specifying the type.
      * @param size An int specifying the size.
+     * @deprecated Associated Column maps should be populated using it's set 
+     *             methods, then added to table via addColumn(ColumnMap).
+     *             This method will be removed in a future version of Torque.
      */
     public void addColumn(String columnName, Object type, int size)
     {
@@ -325,6 +383,9 @@
      *
      * @param columnName A String with the column name.
      * @param type An Object specifying the type.
+     * @deprecated Associated Column maps should be populated using it's set 
+     *             methods, then added to table via addColumn(ColumnMap).
+     *             This method will be removed in a future version of Torque.
      */
     public void addPrimaryKey(String columnName, Object type)
     {
@@ -337,6 +398,9 @@
      * @param columnName A String with the column name.
      * @param type An Object specifying the type.
      * @param size An int specifying the size.
+     * @deprecated Associated Column maps should be populated using it's set 
+     *             methods, then added to table via addColumn(ColumnMap).
+     *             This method will be removed in a future version of Torque.
      */
     public void addPrimaryKey(String columnName, Object type, int size)
     {
@@ -350,9 +414,12 @@
      * @param type An Object specifying the type.
      * @param fkTable A String with the foreign key table name.
      * @param fkColumn A String with the foreign key column name.
+     * @deprecated Associated Column maps should be populated using it's set 
+     *             methods, then added to table via addColumn(ColumnMap).
+     *             This method will be removed in a future version of Torque.
      */
-    public void addForeignKey(String columnName,
-                              Object type,
+    public void addForeignKey(String columnName, 
+                              Object type, 
                               String fkTable,
                               String fkColumn)
     {
@@ -367,12 +434,15 @@
      * @param fkTable A String with the foreign key table name.
      * @param fkColumn A String with the foreign key column name.
      * @param size An int specifying the size.
+     * @deprecated Associated Column maps should be populated using it's set 
+     *             methods, then added to table via addColumn(ColumnMap).
+     *             This method will be removed in a future version of Torque.
      */
-    public void addForeignKey(String columnName,
-                              Object type,
+    public void addForeignKey(String columnName, 
+                              Object type, 
                               String fkTable,
-                              String fkColumn,
-                              int size)
+                               String fkColumn,
+                               int size)
     {
         addColumn(columnName, type, false, fkTable, fkColumn, size);
     }
@@ -384,10 +454,13 @@
      * @param type An Object specifying the type.
      * @param fkTable A String with the foreign key table name.
      * @param fkColumn A String with the foreign key column name.
+     * @deprecated Associated Column maps should be populated using it's set 
+     *             methods, then added to table via addColumn(ColumnMap).
+     *             This method will be removed in a future version of Torque.
      */
-    public void addForeignPrimaryKey(String columnName,
+    public void addForeignPrimaryKey(String columnName, 
                                      Object type,
-                                     String fkTable,
+                                     String fkTable, 
                                      String fkColumn)
     {
         addColumn(columnName, type, true, fkTable, fkColumn, 0);
@@ -401,11 +474,14 @@
      * @param fkTable A String with the foreign key table name.
      * @param fkColumn A String with the foreign key column name.
      * @param size An int specifying the size.
+     * @deprecated Associated Column maps should be populated using it's set 
+     *             methods, then added to table via addColumn(ColumnMap).
+     *             This method will be removed in a future version of Torque.
      */
-    public void addForeignPrimaryKey(String columnName,
+    public void addForeignPrimaryKey(String columnName, 
                                      Object type,
-                                     String fkTable,
-                                     String fkColumn,
+                                     String fkTable, 
+                                     String fkColumn, 
                                      int size)
     {
         addColumn(columnName, type, true, fkTable, fkColumn, size);
@@ -420,15 +496,18 @@
      * @param fkTable A String with the foreign key table name.
      * @param fkColumn A String with the foreign key column name.
      * @param size An int specifying the size.
+     * @deprecated Associated Column maps should be populated using it's set 
+     *             methods, then added to table via addColumn(ColumnMap).
+     *             This method will be removed in a future version of Torque.
      */
-    private void addColumn(String name,
-                           Object type,
+    private void addColumn(String name, 
+                           Object type, 
                            boolean pk,
-                           String fkTable,
-                           String fkColumn,
+                           String fkTable, 
+                           String fkColumn, 
                            int size)
     {
-        addColumn(name, type, pk, fkTable,fkColumn, size, 0 );
+        addColumn(name, type, pk, fkTable, fkColumn, size, 0);
     }
 
     /**
@@ -441,13 +520,16 @@
      * @param fkColumn A String with the foreign key column name.
      * @param size An int specifying the size.
      * @param scale An int specifying the scale.
+     * @deprecated Associated Column maps should be populated using it's set 
+     *             methods, then added to table via addColumn(ColumnMap).
+     *             This method will be removed in a future version of Torque.
      */
-    private void addColumn(String name,
-                           Object type,
+    private void addColumn(String name, 
+                           Object type, 
                            boolean pk,
-                           String fkTable,
-                           String fkColumn,
-                           int size,
+                           String fkTable, 
+                           String fkColumn, 
+                           int size, 
                            int scale)
     {
         // If the tablename is prefixed with the name of the column,
@@ -564,4 +646,134 @@
         }
         return out.toString();
     }
-}
+
+    /**
+     * Returns the table description info.
+     * 
+     * @return Returns the description.
+     */
+    public String getDescription()
+    {
+        return description;
+    }
+
+    /**
+     * Sets the table description.
+     * 
+     * @param description The description to set.
+     */
+    public void setDescription(String description)
+    {
+        this.description = description;
+    }
+
+    /**
+     * Returns the OM class for this table. 
+     * 
+     * @return the OM class.
+     */
+    public Class getOMClass()
+    {
+        return omClass;
+    }
+
+    /**
+     * Sets the OM root class for this table.
+     * 
+     * @param omClass The OM root class for this table.
+     */
+    public void setOMClass(Class omClass)
+    {
+        this.omClass = omClass;
+    }
+
+    /**
+     * Returns the Peer Class for this table.
+     * 
+     * @return The peerClass for this table.
+     */
+    public Class getPeerClass()
+    {
+        return peerClass;
+    }
+
+    /**
+     * Sets the Peer class for this table.
+     * 
+     * @param peerClassName The peerClass to set.
+     */
+    public void setPeerClass(Class peerClass)
+    {
+        this.peerClass = peerClass;
+    }
+
+    /**
+     * Returns the database map for this table.
+     * 
+     * @return the database map for this table.
+     */
+    public DatabaseMap getDbMap()
+    {
+        return dbMap;
+    }
+
+    /**
+     * Returns whether this table uses inheritance.
+     * 
+     * @return whether inheritance is used.
+     */
+    public boolean isUseInheritance()
+    {
+        return useInheritance;
+    }
+
+    /**
+     * Sets whether this table uses inheritance.
+     * 
+     * @param useInheritance whether this table uses inheritance.
+     */
+    public void setUseInheritance(boolean useInheritance)
+    {
+        this.useInheritance = useInheritance;
+    }
+
+    /**
+     * Returns whether managers are used for this table.
+     * 
+     * @return whether managers are used for this table.
+     */
+    public boolean isUseManager()
+    {
+        return useManager;
+    }
+
+    /**
+     * Sets whether managers are used for this table.
+     * 
+     * @param useManager whether managers are used for this table.
+     */
+    public void setUseManager(boolean useManager)
+    {
+        this.useManager = useManager;
+    }
+
+    /**
+     * Returns the manager class for this table.
+     * 
+     * @return the managerClass.
+     */
+    public Class getManagerClass()
+    {
+        return managerClass;
+    }
+
+    /**
+     * Sets the manager class for this table.
+     * 
+     * @param managerClass the manager class for this table.
+     */
+    public void setManagerClass(Class managerClass)
+    {
+        this.managerClass = managerClass;
+    }
+}
\ No newline at end of file

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/om/BaseObject.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/om/BaseObject.java?rev=414531&r1=414530&r2=414531&view=diff
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/om/BaseObject.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/om/BaseObject.java Thu Jun 15 03:07:45 2006
@@ -23,6 +23,7 @@
 import org.apache.commons.logging.LogFactory;
 
 import org.apache.torque.TorqueException;
+import org.apache.torque.map.TableMap;
 
 /**
  * This class contains attributes and methods that are used by all
@@ -294,4 +295,16 @@
      * @see org.apache.torque.om.Persistent#save(Connection)
      */
     public abstract void save(Connection con) throws Exception;
+    
+    /**
+     * Retrieves the TableMap object related to this Table data. 
+     * Must be overridden in generated classes.  If BaseObject's 
+     * implementation is called it will throw an Error.
+     *
+     * @return The associated TableMap object.
+     */
+    public TableMap getTableMap() throws TorqueException
+    {
+        throw new Error("BaseObject.getTableMap: " + NOT_IMPLEMENTED);
+    }
 }

Modified: db/torque/runtime/trunk/xdocs/reference/initialisation-configuration.xml
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/xdocs/reference/initialisation-configuration.xml?rev=414531&r1=414530&r2=414531&view=diff
==============================================================================
--- db/torque/runtime/trunk/xdocs/reference/initialisation-configuration.xml (original)
+++ db/torque/runtime/trunk/xdocs/reference/initialisation-configuration.xml Thu Jun 15 03:07:45 2006
@@ -49,6 +49,9 @@
       i.e. the <code>DatabaseMaps</code>, are built by autogenerated
       <code>MapBuilder</code>classes.  This happens automatically,
       so usually you need not bother about it.
+    </p>
+    
+    <p>
       The detailed procedure is the following: Each peer class registers
       its Map builder with the Torque runtime when the Base Peer Class is loaded
       (Usually, a peer class is loaded if one of the constants
@@ -58,6 +61,14 @@
       instantly and makes it avaliable to Torque. If Torque is not yet
       initialized, the Peer class stores the Map Builder with Torque,
       which builds the database Map when Torque is initialized.
+    </p>
+    
+    <p>
+      This means that you will not see a table in the database map if
+      its peer class is not loaded.  If you want to make sure that all
+      tables appear in the Database map, call the Database Map's
+      initialize() method. This method triggers a generated class
+      to insert all tables into the database map.
     </p>
 
   </section>

Modified: db/torque/site/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/db/torque/site/trunk/xdocs/changes.xml?rev=414531&r1=414530&r2=414531&view=diff
==============================================================================
--- db/torque/site/trunk/xdocs/changes.xml (original)
+++ db/torque/site/trunk/xdocs/changes.xml Thu Jun 15 03:07:45 2006
@@ -29,6 +29,13 @@
 
   <release version="3.2.1-dev" date="in SVN">
   
+    <action type="add" dev="tfischer" issue="TORQUE-22" due-to="Greg Monroe">
+      A database map can now load all contained tableMaps
+      using its method databaseMap.initialize().
+    </action>
+    <action type="add" dev="tfischer" issue="TORQUE-22" due-to="Greg Monroe">
+      The database maps now provide all information from the schema.xml.
+    </action>
     <action type="add" dev="tfischer" issue="TORQUE-25" due-to="Martin Goulet">
       Improved performance for sybase limit using SET ROWCOUNT.
     </action>

Modified: db/torque/templates/trunk/src/templates/om/Control.vm
URL: http://svn.apache.org/viewvc/db/torque/templates/trunk/src/templates/om/Control.vm?rev=414531&r1=414530&r2=414531&view=diff
==============================================================================
--- db/torque/templates/trunk/src/templates/om/Control.vm (original)
+++ db/torque/templates/trunk/src/templates/om/Control.vm Thu Jun 15 03:07:45 2006
@@ -17,6 +17,10 @@
 
 correctGetters = $!correctGetters
 
+#set ( $mapDBNames = [] )       ## Collect unique DB names across all external-schemas
+#set ( $mapDatabases = [] )     ## Collect the first database object across all external-schemas
+#set ( $mapDBMapBuilders = [] ) ## Collect all table map builders across all external-schemas
+
 #foreach ($database in $dataModels)
 
     #if ($database.Package)
@@ -117,6 +121,25 @@
       $files.mkdir("$outputDirectory/$path")
     #end
 
+	#if ( !$mapDBNames.contains( $database.Name ) )
+## Adding new database entry for $database.Name	
+	  #set ( $retVal = $mapDBNames.add( $database.Name ) )
+	  #set ( $retVal = $mapDatabases.add( $database ) )
+	  #set ( $builderArray = [] ) 
+	  #set ( $retVal = $mapDBMapBuilders.add( $builderArray ) )
+	#else
+## Using existing database entry for $database.Name
+	  #set ( $dbIndex = $mapDBinfo.indexOf( $database.Name ) )
+	  #set ( $builderArray = $mapDBMapBuilders.get( $dbIndex ) )
+	#end
+	
+	#foreach ($tbl in $database.Tables)
+	  #if ( !$tbl.isAlias() && !$tbl.isForReferenceOnly() )
+## Adding new table Peer = "${packagePeer}.${tbl.JavaName}Peer"
+	    #set ($retVar = $builderArray.add("${packagePeer}.${tbl.JavaName}Peer") )
+	  #end
+	#end
+
     #foreach ($tbl in $database.Tables)
       #if (!$tbl.isForReferenceOnly())
         $tbl.Name
@@ -217,4 +240,38 @@
         #end
       #end
     #end
+#end
+
+#foreach ( $dbName in $mapDBNames )
+	#set ( $dbIndex = $mapDBNames.indexOf( $dbName ) )
+	#set ( $peerNames = $mapDBMapBuilders.get( $dbIndex ) )
+	#set ( $database = $mapDatabases.get( $dbIndex ) )
+
+    #if ($database.Package)
+      #set ($package = $database.Package)
+    #else
+      #set ($package = $targetPackage)
+    #end
+
+    #if ($subpackageMap)
+      #set ($packageMap = "${package}.${subpackageMap}")
+    #else
+      #set ($packageMap = "${package}")
+    #end
+
+    #set ( $fname = "${database.JavaName}MapInit.java" )
+    #set ( $path = "${strings.getPackageAsPath($packageMap)}$fname" )
+    $generator.parse("om/DatabaseMapInit.vm", $path, "database", $database)
+
+## Hard coded linkage package that must match one used by runtime DatabaseMap.initialize()
+	#set ( $packageLinkage = "org.apache.torque.linkage" );
+	#set ( $path = $strings.getPackageAsPath($packageLinkage) )
+    $files.mkdir("$outputDirectory/$path")
+	
+    #set ( $fname = "${database.StandardJavaName}MapInit.java" )
+    #set ( $path = "$strings.getPackageAsPath($packageLinkage)$fname" )
+    #if (!$files.file($basePath,$path).exists())
+      $generator.parse("om/DatabaseMapInitLinkageObject.vm", $path, "database", $database)
+    #end
+
 #end

Added: db/torque/templates/trunk/src/templates/om/DatabaseMapInit.vm
URL: http://svn.apache.org/viewvc/db/torque/templates/trunk/src/templates/om/DatabaseMapInit.vm?rev=414531&view=auto
==============================================================================
--- db/torque/templates/trunk/src/templates/om/DatabaseMapInit.vm (added)
+++ db/torque/templates/trunk/src/templates/om/DatabaseMapInit.vm Thu Jun 15 03:07:45 2006
@@ -0,0 +1,35 @@
+## Copyright 2001-2006 The Apache Software Foundation.
+##
+## Licensed 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.
+package ${packageMap};
+
+import org.apache.torque.TorqueException;
+
+/**
+ * This is a Torque Generated class that is used to load all database map 
+ * information at once.  This is useful because Torque's default behaviour
+ * is to do a "lazy" load of mapping information, e.g. loading it only
+ * when it is needed.<p>
+ *
+ * @see org.apache.torque.map.DatabaseMap#initialize() DatabaseMap.initialize() 
+ */
+public class ${database.JavaName}MapInit
+{
+	public static final void init()
+		throws TorqueException
+	{
+#foreach ( $peer in $peerNames )
+        ${peer}.getMapBuilder();
+#end
+    }
+}

Added: db/torque/templates/trunk/src/templates/om/DatabaseMapInitLinkageObject.vm
URL: http://svn.apache.org/viewvc/db/torque/templates/trunk/src/templates/om/DatabaseMapInitLinkageObject.vm?rev=414531&view=auto
==============================================================================
--- db/torque/templates/trunk/src/templates/om/DatabaseMapInitLinkageObject.vm (added)
+++ db/torque/templates/trunk/src/templates/om/DatabaseMapInitLinkageObject.vm Thu Jun 15 03:07:45 2006
@@ -0,0 +1,28 @@
+## Copyright 2001-2006 The Apache Software Foundation.
+##
+## Licensed 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.
+package ${packageLinkage};
+
+/**
+ * This Torque generated class is used to link the runtime code 
+ * in org.apache.torque.* packages to the Database specific MapInit 
+ * classes generated in the user defined packages.  It resided in 
+ * the ${packageLinkage} so that the runtime code can 
+ * locate it regardless of the user build properties.
+ *
+ * @see org.apache.torque.map.DatabaseMap#initialize() DatabaseMap.initialize() 
+ */
+public class ${database.StandardJavaName}MapInit
+		extends ${packageMap}.${database.JavaName}MapInit
+{
+}

Modified: db/torque/templates/trunk/src/templates/om/MapBuilder.vm
URL: http://svn.apache.org/viewvc/db/torque/templates/trunk/src/templates/om/MapBuilder.vm?rev=414531&r1=414530&r2=414531&view=diff
==============================================================================
--- db/torque/templates/trunk/src/templates/om/MapBuilder.vm (original)
+++ db/torque/templates/trunk/src/templates/om/MapBuilder.vm Thu Jun 15 03:07:45 2006
@@ -16,11 +16,16 @@
 import java.util.Date;
 import java.math.BigDecimal;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 import org.apache.torque.Torque;
 import org.apache.torque.TorqueException;
 import org.apache.torque.map.MapBuilder;
 import org.apache.torque.map.DatabaseMap;
 import org.apache.torque.map.TableMap;
+import org.apache.torque.map.ColumnMap;
+import org.apache.torque.map.InheritanceMap;
 
 /**
 #if ($table.description)
@@ -36,6 +41,9 @@
   */
 public class ${table.JavaName}MapBuilder implements MapBuilder
 {
+    /** the log */
+    protected static Log log = LogFactory.getLog(${table.JavaName}MapBuilder.class);
+
     /**
      * The name of this class
      */
@@ -73,63 +81,106 @@
      *
      * @throws TorqueException
      */
-    public void doBuild() throws TorqueException
+    public synchronized void doBuild() throws TorqueException
     {
+    	if ( isBuilt() ) {
+    		return;
+    	}
         dbMap = Torque.getDatabaseMap("$table.Database.Name");
 
         dbMap.addTable("$table.Name");
         TableMap tMap = dbMap.getTable("$table.Name");
-
+        tMap.setJavaName("$table.JavaName");
+        tMap.setOMClass( ${package}.${table.JavaName}.class );
+        tMap.setPeerClass( ${packagePeer}.${table.JavaName}Peer.class );
+#if ( $table.Description )        
+        tMap.setDescription("$table.Description");
+#end        
 #if ($table.IdMethod == "native")
-        tMap.setPrimaryKeyMethod(TableMap.NATIVE);
+	    tMap.setPrimaryKeyMethod(TableMap.NATIVE);
 #elseif ($table.IdMethod == "idbroker")
-        tMap.setPrimaryKeyMethod(TableMap.ID_BROKER);
+    	tMap.setPrimaryKeyMethod(TableMap.ID_BROKER);
 #else
         tMap.setPrimaryKeyMethod("$table.IdMethod");
 #end
-
 #if ($table.IdMethodParameters)
         // this might need upgrading based on what all the databases
         // need, but for now assume one parameter.
   #set ($imp = $table.IdMethodParameters.get(0) )
         tMap.setPrimaryKeyMethodInfo("$imp.Value");
 #elseif ($table.IdMethod == "idbroker")
-        tMap.setPrimaryKeyMethodInfo(tMap.getName());
+    	tMap.setPrimaryKeyMethodInfo(tMap.getName());
 #elseif ($table.IdMethod == "native" && $table.Database.Platform.NativeIdMethod == "sequence")
         tMap.setPrimaryKeyMethodInfo("$table.SequenceName");
 #elseif ($table.IdMethod == "native" && $table.Database.Platform.NativeIdMethod == "identity")
         tMap.setPrimaryKeyMethodInfo("$table.Name");
 #end
+#if ($useManagers && $table.PrimaryKey.size() > 0)
+  #set ($interfaceName = $table.JavaName)
+  #if ($table.Interface)
+    #set ($interfaceName = $table.Interface)
+  #end
+		tMap.setUseManager(true);
+        tMap.setManagerClass( ${packageManager}.${interfaceName}Manager.class );
+#end
+
+        ColumnMap cMap = null;
+
+#set ($tableUseInheritance = "false")
+#set ($position = 1)
 
 #foreach ($col in $table.Columns)
-  #set ( $tfc=$table.JavaName )
   #set ( $cfc=$col.JavaName )
   #set ( $cup=$col.Name.toUpperCase() )
-  #if($col.isPrimaryKey())
-    #if($col.isForeignKey())
-        tMap.addForeignPrimaryKey(
-                "${table.Name}.$cup", $col.JavaObject , "$col.RelatedTableName" ,
-                "$col.RelatedColumnName");
-    #else
-        tMap.addPrimaryKey("${table.Name}.$cup", $col.JavaObject );
+  // ------------- Column: $cup --------------------
+        cMap = new ColumnMap( "$cup", tMap);
+        cMap.setType( $col.JavaObject );
+        cMap.setUsePrimitive($col.UsePrimitive);
+        cMap.setPrimaryKey($col.isPrimaryKey());
+  		cMap.setNotNull($col.isNotNull());
+        cMap.setJavaName( "$cfc" );
+        cMap.setAutoIncrement($col.AutoIncrement);
+  		cMap.setProtected($col.Protected);
+  #if( $col.JavaType )   		
+  		cMap.setJavaType( "${col.JavaType}" );
+  #end
+  #if( $col.Description ) 
+  		cMap.setDescription("${col.Description}");
+  #end  		
+  #if( $col.DefaultValue )
+  		cMap.setDefault("$col.DefaultValue");
+  #end
+  #if( $col.InheritanceType )
+  		cMap.setInheritance("$col.InheritanceType");
+  #end
+  #if( $col.InputValidator )
+  		cMap.setInputValidator("$col.InputValidator");
+  #end
+  #if( $col.JavaNamingMethod )
+  		cMap.setJavaNamingMethod("$col.JavaNamingMethod");
+  #end
+  #if( $col.Precision )
+        cMap.setSize( $col.Precision );
+   	#if( $col.Scale )
+        cMap.setScale( $col.Scale );
     #end
-  #else
-    #if($col.isForeignKey())
-        tMap.addForeignKey(
-                "${table.Name}.$cup", $col.JavaObject , "$col.RelatedTableName" ,
-                "$col.RelatedColumnName");
-    #else
-      #if( $col.Precision )
-      	#if( $col.Scale )
-          tMap.addColumn("${table.Name}.$cup", $col.JavaObject, $col.Precision, $col.Scale );
-        #else
-          tMap.addColumn("${table.Name}.$cup", $col.JavaObject, $col.Precision );
-        #end
-      #else
-        tMap.addColumn("${table.Name}.$cup", $col.JavaObject );
-      #end
+  #end
+  #if($col.isForeignKey())
+  	    cMap.setForeignKey("$col.RelatedTableName", "$col.RelatedColumnName"); 
+  #end
+  #if($col.isInheritance() ) 
+    #set($tableUseInheritance = "true");
+  		cMap.setUseInheritance($col.Inheritance);
+  		InheritanceMap iMap = null;
+    #foreach ($inh in $col.Children)
+        iMap = new InheritanceMap(cMap,"$inh.Key","$inh.ClassName","$inh.Ancestor");
+        cMap.addInheritanceMap(iMap);
     #end
   #end
+        cMap.setPosition($position);
+  #set ($position = $position + 1)
+        tMap.addColumn(cMap);
 #end
+        tMap.setUseInheritance($tableUseInheritance);
     }
 }

Modified: db/torque/templates/trunk/src/templates/om/Object.vm
URL: http://svn.apache.org/viewvc/db/torque/templates/trunk/src/templates/om/Object.vm?rev=414531&r1=414530&r2=414531&view=diff
==============================================================================
--- db/torque/templates/trunk/src/templates/om/Object.vm (original)
+++ db/torque/templates/trunk/src/templates/om/Object.vm Thu Jun 15 03:07:45 2006
@@ -36,6 +36,7 @@
 import org.apache.torque.Torque;
 #end
 import org.apache.torque.TorqueException;
+import org.apache.torque.map.TableMap;
 import org.apache.torque.om.BaseObject;
 import org.apache.torque.om.ComboKey;
 import org.apache.torque.om.DateKey;
@@ -1629,7 +1630,7 @@
         return copyInto(copyObj, true);
     }
   #end
-    
+
     /**
      * Fills the copyObj with the contents of this object.
   #if ($complexObjectModel)
@@ -1696,21 +1697,21 @@
             #set ( $pCollNameNoS = "${className}RelatedBy$relCol" )
           #end
 
-            List#if($enableJava5Features)<$className>#end v${pCollName} = get${pCollName}();
-              ## v can be null if the generator property
-              ## torque.silentDbFetch is set to false
-            if (v${pCollName} != null)
-            {
-                for (int i = 0; i < v${pCollName}.size(); i++)
-                {
-                    ${className} obj = #if(!$enableJava5Features)($className)#end v${pCollName}.get(i);
-                    copyObj.add$pCollNameNoS(obj.copy());
-                }
-            }
-            else
+        List#if($enableJava5Features)<$className>#end v${pCollName} = get${pCollName}();
+          ## v can be null if the generator property
+          ## torque.silentDbFetch is set to false
+        if (v${pCollName} != null)
+        {
+            for (int i = 0; i < v${pCollName}.size(); i++)
             {
-                copyObj.coll${pCollName} = null;
+                ${className} obj = #if(!$enableJava5Features)($className)#end v${pCollName}.get(i);
+                copyObj.add$pCollNameNoS(obj.copy());
             }
+        }
+        else
+        {
+            copyObj.coll${pCollName} = null;
+        }
         #end
       #end
     #end
@@ -1730,6 +1731,19 @@
     public ${table.JavaName}Peer getPeer()
     {
         return peer;
+    }
+#end
+
+#if (!$table.isAlias())
+    /**
+     * Retrieves the TableMap object related to this Table data without
+     * compiler warnings of using getPeer().getTableMap().
+     *
+     * @return The associated TableMap object.
+     */
+    public TableMap getTableMap() throws TorqueException
+    {
+        return ${table.JavaName}Peer.getTableMap();
     }
 #end
 

Modified: db/torque/templates/trunk/src/templates/om/ObjectWithManager.vm
URL: http://svn.apache.org/viewvc/db/torque/templates/trunk/src/templates/om/ObjectWithManager.vm?rev=414531&r1=414530&r2=414531&view=diff
==============================================================================
--- db/torque/templates/trunk/src/templates/om/ObjectWithManager.vm (original)
+++ db/torque/templates/trunk/src/templates/om/ObjectWithManager.vm Thu Jun 15 03:07:45 2006
@@ -36,6 +36,7 @@
 import org.apache.torque.Torque;
 #end
 import org.apache.torque.TorqueException;
+import org.apache.torque.map.TableMap;
 import org.apache.torque.om.BaseObject;
 import org.apache.torque.om.ComboKey;
 import org.apache.torque.om.DateKey;
@@ -1633,7 +1634,7 @@
     {
         return copyInto(new ${table.JavaName}(), deepcopy);
     }
-    #end
+  #end
   #end
 
   #if ($complexObjectModel)
@@ -1647,7 +1648,7 @@
         return copyInto(copyObj, true);
     }
   #end
-    
+
     /**
      * Fills the copyObj with the contents of this object.
   #if ($complexObjectModel)
@@ -1672,8 +1673,8 @@
   #foreach ($col in $table.Columns)
     #if ($col.isPrimaryKey())
       #if($col.Primitive)
-		#set ($fktype = $col.JavaNative)
-	    #set ($casttype = "")
+        #set ($fktype = $col.JavaNative)
+        #set ($casttype = "")
         #if ($fktype == "short")
           #set ($casttype = "(short)")
         #elseif($fktype == "byte")
@@ -1714,21 +1715,21 @@
             #set ( $pCollNameNoS = "${className}RelatedBy$relCol" )
           #end
 
-            List#if($enableJava5Features)<$className>#end v${pCollName} = get${pCollName}();
-              ## v can be null if the generator property
-              ## torque.silentDbFetch is set to false
-            if (v${pCollName} != null)
-            {
-                for (int i = 0; i < v${pCollName}.size(); i++)
-                {
-                    ${className} obj = #if(!$enableJava5Features)($className)#end v${pCollName}.get(i);
-                    copyObj.add$pCollNameNoS(obj.copy());
-                }
-            }
-            else
+        List#if($enableJava5Features)<$className>#end v${pCollName} = get${pCollName}();
+          ## v can be null if the generator property
+          ## torque.silentDbFetch is set to false
+        if (v${pCollName} != null)
+        {
+            for (int i = 0; i < v${pCollName}.size(); i++)
             {
-                copyObj.coll${pCollName} = null;
+                ${className} obj = #if(!$enableJava5Features)($className)#end v${pCollName}.get(i);
+                copyObj.add$pCollNameNoS(obj.copy());
             }
+        }
+        else
+        {
+            copyObj.coll${pCollName} = null;
+        }
         #end
       #end
     #end
@@ -1748,6 +1749,19 @@
     public ${table.JavaName}Peer getPeer()
     {
         return peer;
+    }
+#end
+
+#if (!$table.isAlias())
+    /**
+     * Retrieves the TableMap object related to this Table data without
+     * compiler warnings of using getPeer().getTableMap().
+     *
+     * @return The associated TableMap object.
+     */
+    public TableMap getTableMap() throws TorqueException
+    {
+        return ${table.JavaName}Peer.getTableMap();
     }
 #end
 

Modified: db/torque/templates/trunk/src/templates/om/Peer.vm
URL: http://svn.apache.org/viewvc/db/torque/templates/trunk/src/templates/om/Peer.vm?rev=414531&r1=414530&r2=414531&view=diff
==============================================================================
--- db/torque/templates/trunk/src/templates/om/Peer.vm (original)
+++ db/torque/templates/trunk/src/templates/om/Peer.vm Thu Jun 15 03:07:45 2006
@@ -69,10 +69,10 @@
 #if (!$table.isAlias())
 
     /** the default database name for this class */
-    public static final String DATABASE_NAME = "$table.Database.Name";
+    public static final String DATABASE_NAME;
 
      /** the table name for this class */
-    public static final String TABLE_NAME = "$table.Name";
+    public static final String TABLE_NAME;
 
     /**
      * @return the map builder for this peer
@@ -95,6 +95,9 @@
 
     static
     {
+        DATABASE_NAME = "$table.Database.Name";
+        TABLE_NAME = "$table.Name";
+
   #foreach ($col in $table.Columns)
     #set ( $tfc=$table.JavaName )
     #set ( $cfc=$col.JavaName )
@@ -1456,13 +1459,12 @@
 
   #if (!$table.isAlias())
     /**
-     * Returns the TableMap related to this peer.  This method is not
-     * needed for general use but a specific application could have a need.
+     * Returns the TableMap related to this peer.
      *
      * @throws TorqueException Any exceptions caught during processing will be
      *         rethrown wrapped into a TorqueException.
      */
-    protected static TableMap getTableMap()
+    public static TableMap getTableMap()
         throws TorqueException
     {
         return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME);



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