You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by jg...@apache.org on 2009/03/06 22:08:43 UTC

svn commit: r751073 - in /ibatis/trunk/java/tools/ibator/core: build/ htmldoc/ htmldoc/configreference/ htmldoc/usage/ src/org/apache/ibatis/ibator/config/ src/org/apache/ibatis/ibator/config/xml/ src/org/apache/ibatis/ibator/internal/db/ src/org/apach...

Author: jgbutler
Date: Fri Mar  6 21:08:42 2009
New Revision: 751073

URL: http://svn.apache.org/viewvc?rev=751073&view=rev
Log:
[Ibator] Some enhancements to deal with PostreSQL weirdness

Added:
    ibatis/trunk/java/tools/ibator/core/htmldoc/usage/postgresql.html
Modified:
    ibatis/trunk/java/tools/ibator/core/build/version.properties
    ibatis/trunk/java/tools/ibator/core/htmldoc/configreference/table.html
    ibatis/trunk/java/tools/ibator/core/htmldoc/menu.html
    ibatis/trunk/java/tools/ibator/core/htmldoc/usage/intro.html
    ibatis/trunk/java/tools/ibator/core/htmldoc/whatsNew.html
    ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/TableConfiguration.java
    ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/xml/IbatorConfigurationParser.java
    ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/xml/ibator-config_1_0.dtd
    ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/DatabaseIntrospector.java
    ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/types/JavaTypeResolverDefaultImpl.java
    ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/plugins/CaseInsensitiveLikePlugin.java

Modified: ibatis/trunk/java/tools/ibator/core/build/version.properties
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/build/version.properties?rev=751073&r1=751072&r2=751073&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/build/version.properties (original)
+++ ibatis/trunk/java/tools/ibator/core/build/version.properties Fri Mar  6 21:08:42 2009
@@ -1,4 +1,4 @@
 #Ibator build version info
-#Mon Feb 23 14:36:25 CST 2009
+#Fri Mar 06 13:35:30 CST 2009
 version=1.2.2
-buildNum=714
+buildNum=715

Modified: ibatis/trunk/java/tools/ibator/core/htmldoc/configreference/table.html
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/htmldoc/configreference/table.html?rev=751073&r1=751072&r2=751073&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/htmldoc/configreference/table.html (original)
+++ ibatis/trunk/java/tools/ibator/core/htmldoc/configreference/table.html Fri Mar  6 21:08:42 2009
@@ -240,6 +240,17 @@
         <code>schema</code>, or <code>tableName</code> attributes
         contain a space, then <i>true</i>.</p></td>
   </tr>
+  <tr>
+    <td valign="top">delimitAllColumns</td>
+    <td>Signifies whether Ibator should add delimiters to all column names in the generated
+        SQL.  This is an alternative to coding a <code>&lt;columnOverride&gt;</code>
+        for every column
+        specifying that the column should be delimited.  This is useful for databases
+        like PostgreSQL that are case sensitive with identifiers.
+        <p>The delimiter characters are specified on the
+        <a href="ibatorContext.html">&lt;ibatorContext&gt;</a> element.</p>
+        <p>The default is <i>false</i>.</p></td>
+  </tr>
 </table>
 
 <h2>Child Elements</h2>

Modified: ibatis/trunk/java/tools/ibator/core/htmldoc/menu.html
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/htmldoc/menu.html?rev=751073&r1=751072&r2=751073&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/htmldoc/menu.html (original)
+++ ibatis/trunk/java/tools/ibator/core/htmldoc/menu.html Fri Mar  6 21:08:42 2009
@@ -46,6 +46,7 @@
   &nbsp;&nbsp;<a href="usage/db2.html" target="mainFrame">DB2</a><br/>
   &nbsp;&nbsp;<a href="usage/mysql.html" target="mainFrame">MySql</a><br/>
   &nbsp;&nbsp;<a href="usage/oracle.html" target="mainFrame">Oracle</a><br/>
+  &nbsp;&nbsp;<a href="usage/postgresql.html" target="mainFrame">PostgreSQL</a><br/>
 
   <a href="reference/intro.html" target="mainFrame">Other Reference Information</a><br/>
   &nbsp;&nbsp;<a href="reference/building.html" target="mainFrame">Building Ibator from Source</a><br/>

Modified: ibatis/trunk/java/tools/ibator/core/htmldoc/usage/intro.html
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/htmldoc/usage/intro.html?rev=751073&r1=751072&r2=751073&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/htmldoc/usage/intro.html (original)
+++ ibatis/trunk/java/tools/ibator/core/htmldoc/usage/intro.html Fri Mar  6 21:08:42 2009
@@ -22,6 +22,7 @@
   <li><a href="db2.html">DB2</a></li>
   <li><a href="mysql.html">MySql</a></li>
   <li><a href="oracle.html">Oracle</a></li>
+  <li><a href="postgresql.html">PostgreSQL</a></li>
 </ul>
 <p>Please let us know about any quirks you discover for the database you are using - we will
 be happy to add the information

Added: ibatis/trunk/java/tools/ibator/core/htmldoc/usage/postgresql.html
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/htmldoc/usage/postgresql.html?rev=751073&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/htmldoc/usage/postgresql.html (added)
+++ ibatis/trunk/java/tools/ibator/core/htmldoc/usage/postgresql.html Fri Mar  6 21:08:42 2009
@@ -0,0 +1,46 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+  <title>Ibator PostgreSQL Usage Notes</title>
+  <link type="text/css" rel="stylesheet" href="../ibator.css"/>
+</head>
+<body>
+
+<div class="menuNav">
+  <p>
+    <a href="../index.html" target="_top">Show Menu</a>
+    <a href="postgresql.html" target="_top">Hide Menu</a>
+  </p>
+</div>
+
+<h1>Ibator PostgreSQL Usage Notes</h1>
+<h2>Case Sensitivity</h2>
+<p>PostgreSQL is case sensitive with regards to all database identifiers
+(table names, schema names, column names, etc.)  In addition, PostgreSQL
+has a distinct preference for all identifiers being in all lower case letters.
+If you use all lower case identifiers for PostgreSQL, then Ibator will find tables
+and write correct SQL with no additional consideration.  If you used mixed cased,
+or upper case, identifiers you will
+need to configure Ibator appropriately.</p>
+<p>Use the <code>delimitIdentifiers</code> option if your table or schema
+is mixed case or all upper case.</p>
+<p>For each mixed case or upper case column you could specify a
+<code>&lt;columnOverride&gt;</code> element to specifically delimit the column,
+or you could specify the <code>delimitAllColumns</code> attribute
+to delimit all column names.</p>
+<p>Examples:</p>
+<pre>
+  &lt;table schema="HR" tableName="Employees"
+      delimitIdentifiers="true" delimitAllColumns="true"/&gt;
+</pre>
+<p>Or...</p>
+<pre>
+  &lt;table schema="HR" tableName="Employees" delimitIdentifiers="true" &gt;
+    &lt;columnOverride column="EmployeeId" delimitedColumnName="true" /&gt;
+    &lt;columnOverride column="EmployeeName" delimitedColumnName="true" /&gt;
+  &lt;/table&gt;
+</pre>
+</body>
+</html>

Modified: ibatis/trunk/java/tools/ibator/core/htmldoc/whatsNew.html
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/htmldoc/whatsNew.html?rev=751073&r1=751072&r2=751073&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/htmldoc/whatsNew.html (original)
+++ ibatis/trunk/java/tools/ibator/core/htmldoc/whatsNew.html Fri Mar  6 21:08:42 2009
@@ -49,6 +49,13 @@
       support to generated Example classes. See the
      <a href="configreference/ibatorPlugin.html">&lt;ibatorPlugin&gt;</a> page
       for more information.</li>
+  <li>Added "delimitAllColumns" attribute to table configurations.  This suppports databases
+      like PosgreSQL that are case sensitive for identifiers. See the
+     <a href="configreference/table.html">&lt;table&gt;</a> page
+      for more information.</li>
+  <li>Added a page explaining how to deal with case sensitivity in PostgreSQL.  See the
+     <a href="usage/postgresql.html">PostgreSQL</a> page
+      for more information.</li>
 </ul>
 
 <h2>Version 1.2.1</h2>

Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/TableConfiguration.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/TableConfiguration.java?rev=751073&r1=751072&r2=751073&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/TableConfiguration.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/TableConfiguration.java Fri Mar  6 21:08:42 2009
@@ -69,6 +69,7 @@
     private boolean delimitIdentifiers;
     
     private ColumnRenamingRule columnRenamingRule;
+    private boolean isAllColumnDelimitingEnabled;
     
 	public TableConfiguration(IbatorContext ibatorContext) {
 		super();
@@ -401,6 +402,14 @@
             xmlElement.addAttribute(new Attribute("escapeWildcards", "true")); //$NON-NLS-1$ //$NON-NLS-2$
         }
         
+        if (isAllColumnDelimitingEnabled) {
+            xmlElement.addAttribute(new Attribute("delimitAllColumns", "true")); //$NON-NLS-1$ //$NON-NLS-2$
+        }
+        
+        if (delimitIdentifiers) {
+            xmlElement.addAttribute(new Attribute("delimitIdentifiers", "true")); //$NON-NLS-1$ //$NON-NLS-2$
+        }
+        
         addPropertyXmlElements(xmlElement);
         
         if (generatedKey != null) {
@@ -507,4 +516,12 @@
     public void setColumnRenamingRule(ColumnRenamingRule columnRenamingRule) {
         this.columnRenamingRule = columnRenamingRule;
     }
+
+    public boolean isAllColumnDelimitingEnabled() {
+        return isAllColumnDelimitingEnabled;
+    }
+
+    public void setAllColumnDelimitingEnabled(boolean isAllColumnDelimitingEnabled) {
+        this.isAllColumnDelimitingEnabled = isAllColumnDelimitingEnabled;
+    }
 }

Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/xml/IbatorConfigurationParser.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/xml/IbatorConfigurationParser.java?rev=751073&r1=751072&r2=751073&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/xml/IbatorConfigurationParser.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/xml/IbatorConfigurationParser.java Fri Mar  6 21:08:42 2009
@@ -344,7 +344,8 @@
                 .getProperty("selectByExampleQueryId"); //$NON-NLS-1$
         String modelType = attributes.getProperty("modelType"); //$NON-NLS-1$
         String escapeWildcards = attributes.getProperty("escapeWildcards"); //$NON-NLS-1$
-        String delmitIdentifiers = attributes.getProperty("delimitIdentifiers"); //$NON-NLS-1$
+        String delimitIdentifiers = attributes.getProperty("delimitIdentifiers"); //$NON-NLS-1$
+        String delimitAllColumns = attributes.getProperty("delimitAllColumns"); //$NON-NLS-1$
 
         if (StringUtility.stringHasValue(catalog)) {
             tc.setCatalog(catalog);
@@ -414,8 +415,12 @@
             tc.setWildcardEscapingEnabled(StringUtility.isTrue(escapeWildcards));
         }
 
-        if (StringUtility.stringHasValue(delmitIdentifiers)) {
-            tc.setDelimitIdentifiers(StringUtility.isTrue(delmitIdentifiers));
+        if (StringUtility.stringHasValue(delimitIdentifiers)) {
+            tc.setDelimitIdentifiers(StringUtility.isTrue(delimitIdentifiers));
+        }
+        
+        if (StringUtility.stringHasValue(delimitAllColumns)) {
+            tc.setAllColumnDelimitingEnabled(StringUtility.isTrue(delimitAllColumns));
         }
         
         NodeList nodeList = node.getChildNodes();

Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/xml/ibator-config_1_0.dtd
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/xml/ibator-config_1_0.dtd?rev=751073&r1=751072&r2=751073&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/xml/ibator-config_1_0.dtd (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/xml/ibator-config_1_0.dtd Fri Mar  6 21:08:42 2009
@@ -159,7 +159,8 @@
   selectByExampleQueryId CDATA #IMPLIED
   modelType CDATA #IMPLIED
   escapeWildcards CDATA #IMPLIED
-  delimitIdentifiers CDATA #IMPLIED>
+  delimitIdentifiers CDATA #IMPLIED
+  delimitAllColumns CDATA #IMPLIED>
 
 <!--
   The columnOverride element is used to change certain attributes of the column

Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/DatabaseIntrospector.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/DatabaseIntrospector.java?rev=751073&r1=751072&r2=751073&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/DatabaseIntrospector.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/DatabaseIntrospector.java Fri Mar  6 21:08:42 2009
@@ -276,6 +276,10 @@
                         introspectedColumn.setColumnNameDelimited(true);
                     }
                 }
+                
+                if (tc.isAllColumnDelimitingEnabled()) {
+                    introspectedColumn.setColumnNameDelimited(true);
+                }
             }
         }
     }

Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/types/JavaTypeResolverDefaultImpl.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/types/JavaTypeResolverDefaultImpl.java?rev=751073&r1=751072&r2=751073&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/types/JavaTypeResolverDefaultImpl.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/types/JavaTypeResolverDefaultImpl.java Fri Mar  6 21:08:42 2009
@@ -94,6 +94,7 @@
     public FullyQualifiedJavaType calculateJavaType(IntrospectedColumn introspectedColumn) {
 
         FullyQualifiedJavaType answer;
+        
         switch (introspectedColumn.getJdbcType()) {
         case Types.DECIMAL:
         case Types.NUMERIC:

Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/plugins/CaseInsensitiveLikePlugin.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/plugins/CaseInsensitiveLikePlugin.java?rev=751073&r1=751072&r2=751073&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/plugins/CaseInsensitiveLikePlugin.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/plugins/CaseInsensitiveLikePlugin.java Fri Mar  6 21:08:42 2009
@@ -62,7 +62,7 @@
         InnerClass criteria = null;
         // first, find the Criteria inner class
         for (InnerClass innerClass : topLevelClass.getInnerClasses()) {
-            if ("Criteria".equals(innerClass.getType().getShortName())) {
+            if ("Criteria".equals(innerClass.getType().getShortName())) { //$NON-NLS-1$
                 criteria = innerClass;
                 break;
             }
@@ -88,14 +88,14 @@
             sb.append(introspectedColumn.getJavaProperty());
             sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
             sb.insert(0, "and"); //$NON-NLS-1$
-            sb.append("LikeInsensitive");
+            sb.append("LikeInsensitive"); //$NON-NLS-1$
             method.setName(sb.toString());
             method.setReturnType(FullyQualifiedJavaType.getCriteriaInstance());
 
             sb.setLength(0);
             sb.append("addCriterion(\"upper("); //$NON-NLS-1$
             sb.append(introspectedColumn.getAliasedActualColumnName());
-            sb.append(") like\", value.toUpperCase(), \"");
+            sb.append(") like\", value.toUpperCase(), \""); //$NON-NLS-1$
             sb.append(introspectedColumn.getJavaProperty());
             sb.append("\");"); //$NON-NLS-1$
             method.addBodyLine(sb.toString());