User: dsundstrom
  Date: 01/08/30 16:32:54

  Modified:    src/main/org/jboss/ejb/plugins/cmp/jdbc/metadata
                        JDBCTypeMappingMetaData.java
  Log:
  Rewrote most of the sql generation code. It's much cleaner now.
  
  Added table alias generation code.  Table aliases are prepened with a header.
  The default header is t1_, where 1 is incremented as each header is generated.
  
  Revision  Changes    Path
  1.5       +52 -1     
jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCTypeMappingMetaData.java
  
  Index: JDBCTypeMappingMetaData.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCTypeMappingMetaData.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- JDBCTypeMappingMetaData.java      2001/08/19 22:50:33     1.4
  +++ JDBCTypeMappingMetaData.java      2001/08/30 23:32:54     1.5
  @@ -18,7 +18,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Dain Sundstrom</a>
    *   @author <a href="[EMAIL PROTECTED]">Sebastien Alborini</a>
  - *   @version $Revision: 1.4 $
  + *   @version $Revision: 1.5 $
    */
   public final class JDBCTypeMappingMetaData {
        
  @@ -32,6 +32,10 @@
        
        private final HashMap functionMappings = new HashMap();
   
  +     private final String aliasHeaderPrefix;
  +     private final String aliasHeaderSuffix;
  +     private final int aliasMaxLength;
  +
        /**
         * Constructs a mapping with the data contained in the type-mapping xml element
         * from a jbosscmp-jdbc xml file.
  @@ -63,6 +67,24 @@
                        JDBCFunctionMappingMetaData functionMapping = new 
JDBCFunctionMappingMetaData(mappingElement);
                        
functionMappings.put(functionMapping.getFunctionName().toLowerCase(), functionMapping);
                }
  +             
  +             String prefix = MetaData.getOptionalChildContent(element, 
"alias-header-prefix");
  +             if(prefix == null) {
  +                     prefix = "t";
  +             }
  +             aliasHeaderPrefix = prefix;
  +             
  +             String suffix = MetaData.getOptionalChildContent(element, 
"alias-header-suffix");
  +             if(suffix == null) {
  +                     suffix = "_";
  +             }
  +             aliasHeaderSuffix = suffix;
  +             
  +             String max = MetaData.getOptionalChildContent(element, 
"alias-max-length");
  +             if(max == null) {
  +                     max = "32";
  +             }
  +             aliasMaxLength = Integer.parseInt(max);
        }
        
        /**
  @@ -74,7 +96,36 @@
        public String getName() {
                return name;
        }
  +     
  +     /**
  +      * Gets the prefix for that is used when generating an alias header.  An alias 
header
  +      * is prepended to a generated table alias to prevent name collisions. An 
alias header
  +      * is constructed as folows: aliasHeaderPrefix + int_counter + 
aliasHeaderSuffix
  +      * @return the prefix for alias headers
  +      */
  +     public String getAliasHeaderPrefix() {
  +             return aliasHeaderPrefix;
  +     }
      
  +     /**
  +      * Gets the suffix for that is used when generating an alias header.  An alias 
header
  +      * is prepended to a generated table alias to prevent name collisions. An 
alias header
  +      * is constructed as folows: aliasHeaderPrefix + int_counter + 
aliasHeaderSuffix
  +      * @return the suffix for alias headers
  +      */
  +     public String getAliasHeaderSuffix() {
  +             return aliasHeaderSuffix;
  +     }
  +   
  +     /**
  +      * Gets maximum length of a table alias.
  +      * An alias is constructed as folows: aliasHeader + ejb_ql_identifier_path
  +      * @return the maximum length that a table alias can be
  +      */
  +     public int getAliasMaxLength() {
  +             return aliasMaxLength;
  +     }
  +      
        /**
         * Gets the jdbc type which this class has mapped to the specified java class. 
         * The jdbc type is used to retrieve data from a result set and to set 
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to