Author: jgbutler
Date: Thu Aug 17 09:30:13 2006
New Revision: 432284
URL: http://svn.apache.org/viewvc?rev=432284&view=rev
Log:
Add the ability to escape schema and table names in Abator
Modified:
ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/table.html
ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/whatsNew.html
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/TableConfiguration.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/AbatorConfigurationParser.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/abator-config_1_0.dtd
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/db/DatabaseIntrospector.java
Modified:
ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/table.html
URL:
http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/table.html?rev=432284&r1=432283&r2=432284&view=diff
==============================================================================
---
ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/table.html
(original)
+++
ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/table.html
Thu Aug 17 09:30:13 2006
@@ -63,18 +63,18 @@
</td>
</tr>
<tr>
- <td>catalog</td>
+ <td valign="top">catalog</td>
<td>The database catalog - not required if your database does not use
catalogs,
or if there is a default catalog.</td>
</tr>
<tr>
- <td>alias</td>
+ <td valign="top">alias</td>
<td>If specified, this value will be used to alias the table and all
column names in
any generated SQL select statement. Column names will be aliased with
the pattern
alias_actualColumnName.</td>
</tr>
<tr>
- <td>domainObjectName</td>
+ <td valign="top">domainObjectName</td>
<td>The base name from which generated object names will be generated.
If not specified, Abator will generate a name automatically based on
the tableName. The name (either specified here, or generated
@@ -82,39 +82,45 @@
and DAO class names.</td>
</tr>
<tr>
- <td>enableInsert</td>
- <td>Signifies whether an insert statement should be generated (the default
is true).</td>
+ <td valign="top">enableInsert</td>
+ <td>Signifies whether an insert statement should be generated.
+ <p>The default is <i>true</i>.</p></td>
</tr>
<tr>
- <td>enableSelectByPrimaryKey</td>
- <td>Signifies whether a select by primary key statement should be
generated (the default is true).
+ <td valign="top">enableSelectByPrimaryKey</td>
+ <td>Signifies whether a select by primary key statement should be
generated.
Regardless of this setting, the statement will not be generated if the
- table does not have a primary key.</td>
+ table does not have a primary key.
+ <p>The default is <i>true</i>.</p></td>
</tr>
<tr>
- <td>enableSelectByExample</td>
- <td>Signifies whether a select by example statement should be generated
(the default is true).
- This statement enables many different dynamic queries to be generated
at run time.</td>
+ <td valign="top">enableSelectByExample</td>
+ <td>Signifies whether a select by example statement should be generated.
+ This statement enables many different dynamic queries to be generated
at run time.
+ <p>The default is <i>true</i>.</p></td>
</tr>
<tr>
- <td>enableUpdateByPrimaryKey</td>
- <td>Signifies whether an update by primary key statement should be
generated (the default is true).
+ <td valign="top">enableUpdateByPrimaryKey</td>
+ <td>Signifies whether an update by primary key statement should be
generated.
Regardless of this setting, the statement will not be generated if the
- table does not have a primary key.</td>
+ table does not have a primary key.
+ <p>The default is <i>true</i>.</p></td>
</tr>
<tr>
- <td>enableDeleteByPrimaryKey</td>
- <td>Signifies whether an delete by primary key statement should be
generated (the default is true).
+ <td valign="top">enableDeleteByPrimaryKey</td>
+ <td>Signifies whether an delete by primary key statement should be
generated.
Regardless of this setting, the statement will not be generated if the
- table does not have a primary key.</td>
+ table does not have a primary key.
+ <p>The default is <i>true</i>.</p></td>
</tr>
<tr>
- <td>enableDeleteByExample</td>
- <td>Signifies whether a delete by example statement should be generated
(the default is true).
- This statement enables many different dynamic deletes to be generated
at run time.</td>
+ <td valign="top">enableDeleteByExample</td>
+ <td>Signifies whether a delete by example statement should be generated.
+ This statement enables many different dynamic deletes to be generated
at run time.
+ <p>The default is <i>true</i>.</p></td>
</tr>
<tr>
- <td>selectByPrimaryKeyQueryId</td>
+ <td valign="top">selectByPrimaryKeyQueryId</td>
<td>This value will be added to the select list of the select by primary
key statement
in this form: "'<value>' as QUERYID".
This can be useful for identifying queries in DBA tracing tools at run
time.
@@ -122,7 +128,7 @@
generated by Abator.</td>
</tr>
<tr>
- <td>selectByExampleQueryId</td>
+ <td valign="top">selectByExampleQueryId</td>
<td>This value will be added to the select list of the select by example
statement
in this form: "'<value>' as QUERYID".
This can be useful for identifying queries in DBA tracing tools at run
time.
@@ -162,6 +168,14 @@
</tr>
</table>
</td>
+ </tr>
+ <tr>
+ <td valign="top">escapeWildcards</td>
+ <td>Signifies whether SQL wildcards ('_' and '%') in the schema and
tableName should
+ be escaped when searching for columns. This is required by some
drivers if the
+ schema or tableName includes an SQL wildcard (for example, if a table
name is
+ MY_TABLE, some drivers require that the underscore character be
escaped).
+ <p>The default is <i>false</i>.</p></td>
</tr>
</table>
Modified:
ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/whatsNew.html
URL:
http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/whatsNew.html?rev=432284&r1=432283&r2=432284&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/whatsNew.html
(original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/whatsNew.html
Thu Aug 17 09:30:13 2006
@@ -120,18 +120,21 @@
XML configuration.
See the <a href="configreference/table.html"><table></a>
reference page for more information.</li>
+ <li>Added the ability to escape wildcard characters in schema or table names
+ if required by the driver. See the <a
href="configreference/table.html"><table></a>
+ reference page for more information.</li>
<li>Added the ability to suppress JSE 5.0 type warning messages for
non-parameterized
types if you are using the Legacy or Java2 generator sets in a JSE 5.0
environment.
See the <a
href="configreference/abatorContext.html"><abatorContext></a>
reference page for more information.
- </li>
- <li>The Ant task now supports a "verbose" attribute. See the
+ </li>
+ <li>The Ant task now supports a "verbose" attribute. See the
+ <a href="running.html">Running Abator</a> page for more information.
+ </li>
+ <li>The Ant task now supports a nested property set for passing values into
+ an Abator configuration file. See the
<a href="running.html">Running Abator</a> page for more information.
- </li>
- <li>The Ant task now supports a nested property set for passing values into
- an Abator configuration file. See the
- <a href="running.html">Running Abator</a> page for more information.
- </li>
+ </li>
</ul>
</body>
</html>
Modified:
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/TableConfiguration.java
URL:
http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/TableConfiguration.java?rev=432284&r1=432283&r2=432284&view=diff
==============================================================================
---
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/TableConfiguration.java
(original)
+++
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/TableConfiguration.java
Thu Aug 17 09:30:13 2006
@@ -57,6 +57,7 @@
private String domainObjectName;
private String alias;
private ModelType modelType;
+ private boolean wildcardEscapingEnabled;
public TableConfiguration(AbatorContext abatorContext) {
super();
@@ -289,5 +290,13 @@
public void setModelType(ModelType modelType) {
this.modelType = modelType;
+ }
+
+ public boolean isWildcardEscapingEnabled() {
+ return wildcardEscapingEnabled;
+ }
+
+ public void setWildcardEscapingEnabled(boolean wildcardEscapingEnabled) {
+ this.wildcardEscapingEnabled = wildcardEscapingEnabled;
}
}
Modified:
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/AbatorConfigurationParser.java
URL:
http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/AbatorConfigurationParser.java?rev=432284&r1=432283&r2=432284&view=diff
==============================================================================
---
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/AbatorConfigurationParser.java
(original)
+++
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/AbatorConfigurationParser.java
Thu Aug 17 09:30:13 2006
@@ -329,6 +329,7 @@
String selectByExampleQueryId = attributes
.getProperty("selectByExampleQueryId"); //$NON-NLS-1$
String modelType = attributes.getProperty("modelType"); //$NON-NLS-1$
+ String escapeWildcards = attributes.getProperty("escapeWildcards");
//$NON-NLS-1$
if (StringUtility.stringHasValue(catalog)) {
tc.setCatalog(catalog);
@@ -390,6 +391,11 @@
if (StringUtility.stringHasValue(modelType)) {
tc.setModelType(ModelType.getModelType(modelType));
+ }
+
+ if (StringUtility.stringHasValue(escapeWildcards)) {
+ tc.setWildcardEscapingEnabled("true" //$NON-NLS-1$
+ .equals(escapeWildcards));
}
NodeList nodeList = node.getChildNodes();
Modified:
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/abator-config_1_0.dtd
URL:
http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/abator-config_1_0.dtd?rev=432284&r1=432283&r2=432284&view=diff
==============================================================================
---
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/abator-config_1_0.dtd
(original)
+++
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/abator-config_1_0.dtd
Thu Aug 17 09:30:13 2006
@@ -148,7 +148,8 @@
enableDeleteByExample CDATA #IMPLIED
selectByPrimaryKeyQueryId CDATA #IMPLIED
selectByExampleQueryId CDATA #IMPLIED
- modelType CDATA #IMPLIED>
+ modelType CDATA #IMPLIED
+ escapeWildcards CDATA #IMPLIED>
<!--
The columnOverride element is used to change certain attributes of the column
Modified:
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/db/DatabaseIntrospector.java
URL:
http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/db/DatabaseIntrospector.java?rev=432284&r1=432283&r2=432284&view=diff
==============================================================================
---
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/db/DatabaseIntrospector.java
(original)
+++
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/db/DatabaseIntrospector.java
Thu Aug 17 09:30:13 2006
@@ -24,6 +24,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.StringTokenizer;
import org.apache.ibatis.abator.api.FullyQualifiedTable;
import org.apache.ibatis.abator.api.JavaTypeResolver;
@@ -52,7 +53,7 @@
Map introspectedTables = new HashMap();
DatabaseMetaData dbmd = connection.getMetaData();
-
+
String localCatalog;
String localSchema;
String localTableName;
@@ -75,6 +76,37 @@
localCatalog = tc.getCatalog();
localSchema = tc.getSchema();
localTableName = tc.getTableName();
+ }
+
+ if (tc.isWildcardEscapingEnabled()) {
+ String escapeString = dbmd.getSearchStringEscape();
+
+ StringBuffer sb = new StringBuffer();
+ StringTokenizer st;
+ if (localSchema != null) {
+ st = new StringTokenizer(localSchema, "_%", true);
//$NON-NLS-1$
+ while (st.hasMoreTokens()) {
+ String token = st.nextToken();
+ if (token.equals("_") //$NON-NLS-1$
+ || token.equals("%")) { //$NON-NLS-1$
+ sb.append(escapeString);
+ }
+ sb.append(token);
+ }
+ localSchema = sb.toString();
+ }
+
+ sb.setLength(0);
+ st = new StringTokenizer(localTableName, "_%", true); //$NON-NLS-1$
+ while (st.hasMoreTokens()) {
+ String token = st.nextToken();
+ if (token.equals("_") //$NON-NLS-1$
+ || token.equals("%")) { //$NON-NLS-1$
+ sb.append(escapeString);
+ }
+ sb.append(token);
+ }
+ localTableName = sb.toString();
}
ResultSet rs = dbmd.getColumns(localCatalog, localSchema,