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 2006/08/08 00:06:24 UTC
svn commit: r429494 - in
/ibatis/trunk/java/mapper/mapper2/tools/abator/core: doc/ htmldoc/
htmldoc/configreference/ src/org/apache/ibatis/abator/api/
src/org/apache/ibatis/abator/api/dom/java/
src/org/apache/ibatis/abator/config/ src/org/apache/ibatis...
Author: jgbutler
Date: Mon Aug 7 15:06:23 2006
New Revision: 429494
URL: http://svn.apache.org/viewvc?rev=429494&view=rev
Log:
More changes and documentation for IBATIS-328 - add ability to generate a flat domain model in Abator. Also added the ability to generate annotations to ignore type safety warnings in JSE 5.0 environments.
Removed:
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/rules/package.html
Modified:
ibatis/trunk/java/mapper/mapper2/tools/abator/core/doc/ReleaseNotes.txt
ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/abatorContext.html
ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/table.html
ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/intro.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/api/DAOGenerator.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/JavaModelGenerator.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/JavaTypeResolver.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/SqlMapGenerator.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/dom/java/JavaElement.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/AbatorContext.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/ModelType.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/AbatorObjectFactory.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/DefaultDAOMethodNameCalculator.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/ExtendedDAOMethodNameCalculator.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/db/DatabaseIntrospector.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/BaseDAOGenerator.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/BaseLegacyDAOGenerator.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/model/JavaModelGeneratorJava2Impl.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/rules/ConditionalModelRules.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/sqlmap/SqlMapGeneratorIterateImpl.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/types/JavaTypeResolverDefaultImpl.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/util/messages/messages.properties
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/doc/ReleaseNotes.txt
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/doc/ReleaseNotes.txt?rev=429494&r1=429493&r2=429494&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/doc/ReleaseNotes.txt (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/doc/ReleaseNotes.txt Mon Aug 7 15:06:23 2006
@@ -15,6 +15,8 @@
8. Added exampleMethodVisibility as a property for the DAO generator
9. Added methodNameCalculator as a property for the DAO generator
10. Added the ability to specify wildcards for schema and/or tableName in <table>
+11. Added the ability to suppress type warning messages in a JSE 5.0 environment
+12. Added the ability to specify different types of domain models
-------------------------------------------------------------------------------
Version 0.6.5:
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/abatorContext.html
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/abatorContext.html?rev=429494&r1=429493&r2=429494&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/abatorContext.html (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/abatorContext.html Mon Aug 7 15:06:23 2006
@@ -27,6 +27,39 @@
<th>Description</th>
</tr>
<tr>
+ <td valign="top">defaultModelType</td>
+ <td>
+ This property is used to set the default for generated model types.
+ The model type defines how Abator will generate domain classes. With some
+ model types Abator will generate a single domain class for each table,
+ with others Abator may generate different classes depending on the structure
+ of the table. The property supports these values:
+ <table>
+ <tr>
+ <th valign="top">conditional</th>
+ <td><i>This is the default value</i>
+ <br/>This model is similar to the hierarchical model except that a separate
+ class will not be generated if that separate class would only contain
+ one field. So if a table has only one primary key field, that field
+ will be merged into the base record class.</td>
+ </tr>
+ <tr>
+ <th valign="top">flat</th>
+ <td>This model generates only one domain class for any table. The class
+ will hold all fields in the table.</td>
+ </tr>
+ <tr>
+ <th valign="top">hierarchical</th>
+ <td>This model is the same as the model shipped with the initial versions
+ of Abator. This model will generate a primary key class if the table has
+ a primary key, another class that holds any BLOB columns in the table, and
+ another class that holds the remaining fields. There is an appropriate
+ inheritance relationship between the classes.</td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
<td>id</td>
<td>A unique identifier for this context. This value will be used in some
error messages.</td>
@@ -79,6 +112,7 @@
<h2>Child Elements</h2>
<ul>
+ <li><a href="property.html"><property></a> (0..N)</li>
<li><a href="jdbcConnection.html"><jdbcConnection></a> (1 Required)</li>
<li><a href="javaTypeResolver.html"><javaTypeResolver></a> (0 or 1)</li>
<li><a href="javaModelGenerator.html"><javaModelGenerator></a> (1 Required)</li>
@@ -86,6 +120,27 @@
<li><a href="daoGenerator.html"><daoGenerator></a> (0 or 1)</li>
<li><a href="table.html"><table></a> (1..N)</li>
</ul>
+
+<h2>Supported Properties</h2>
+<p>This table lists the properties that can be
+specified with the <a href="property.html"><property></a> child element:</p>
+<table border="1" cellspacing="0" cellpadding="5">
+ <tr>
+ <th>Property Name</th>
+ <th>Property Values</th>
+ </tr>
+ <tr>
+ <td valign="top">suppressTypeWarnings</td>
+ <td>If true, then Abator will add an annotation to any method
+ that uses a non-parameterized type to suppress compiler type warnings.
+ This is useful if you are using the Legacy or Java2 generator sets, but are
+ compiling the generated objects with a JSE 5.0 compiler. In that situation,
+ the Abator generated code would generate many compiler warnings if the
+ annotation is not allowed. This property is not needed and will have
+ no effect when using the Java5 generator set.</p>
+ <p><i>The default value is false.</i></p></td>
+ </tr>
+</table>
</body>
</html>
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=429494&r1=429493&r2=429494&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 Mon Aug 7 15:06:23 2006
@@ -129,6 +129,40 @@
If you use thus value, you should specify a unique id for every different query
generated by Abator.</td>
</tr>
+ <tr>
+ <td valign="top">modelType</td>
+ <td>
+ This property is used to override the default model type if you desire
+ to do so for this table. If not specified, Abator will generate domain
+ objects based on the context default model type.
+ The model type defines how Abator will generate domain classes. With some
+ model types Abator will generate a single domain class for each table,
+ with others Abator may generate different classes depending on the structure
+ of the table. The property supports these values:
+ <table>
+ <tr>
+ <th valign="top">conditional</th>
+ <td>This model is similar to the hierarchical model except that a separate
+ class will not be generated if that separate class would only contain
+ one field. So if a table has only one primary key field, that field
+ will be merged into the base record class.</td>
+ </tr>
+ <tr>
+ <th valign="top">flat</th>
+ <td>This model generates only one domain class for any table. The class
+ will hold all fields in the table.</td>
+ </tr>
+ <tr>
+ <th valign="top">hierarchical</th>
+ <td>This model is the same as the model shipped with the initial versions
+ of Abator. This model will generate a primary key class if the table has
+ a primary key, another class that holds any BLOB columns in the table, and
+ another class that holds the remaining fields. There is an appropriate
+ inheritance relationship between the classes.</td>
+ </tr>
+ </table>
+ </td>
+ </tr>
</table>
<h2>Child Elements</h2>
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/intro.html
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/intro.html?rev=429494&r1=429493&r2=429494&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/intro.html (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/intro.html Mon Aug 7 15:06:23 2006
@@ -23,14 +23,17 @@
</p>
<p>Abator will generate:</p>
<ul>
- <li>Java POJOs that match the table structure including:
+ <li>Java POJOs that match the table structure. This may include:
<ul>
<li>a class to match the primary key of the table (if there is a primary key)</li>
<li>a class to match the non-primary key fields of the table (except BLOB fields)</li>
<li>a class to include the BLOB fields of a table (if the table has BLOB fields)</li>
<li>a class to enable "Query By Example" functionality</li>
</ul>
- <p>There is an inheritance relationship between these classes as appropriate.</p>
+ <p>There is an inheritance relationship between these classes as appropriate.
+ Note that the types of POJOs generated is configurable - you may choose to tell
+ Abator to only generate a single domain object for each table if you so
+ desire.</p>
</li>
<li>iBATIS Compatible SQL Map XML Files. Abator generates SQL for simple
CRUD functions on each table in a configuration. The generated SQL
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=429494&r1=429493&r2=429494&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 Mon Aug 7 15:06:23 2006
@@ -58,25 +58,26 @@
generated by Abator. Abator now supports three different types of domain models
as follows:</p>
<dl>
+ <dt>conditional</dt>
+ <dd>This model is similar to the hierarchical model except that a separate
+ class will not be generated if that separate class would only contain
+ one field. So if a table has only one primary key field, that field
+ will be merged into the base record class. This model type is the default.
+ <b>Note that this model type may generate classes that are not 100%
+ with classes generated in previous versions of Abator.</b></dd>
+ <dt>flat</dt>
+ <dd>This model generates only one domain class for any table. The class
+ will hold all fields in the table.</dd>
<dt>hierarchical</dt>
<dd>This model is the same as the model shipped with the initial versions
of Abator. This model will generate a primary key class if the table has
a primary key, another class that holds any BLOB columns in the table, and
another class that holds the remaining fields. There is an appropriate
inheritance relationship between the classes.</dd>
- <dt>flat</dt>
- <dd>This model generates only one domain class for any table. The class
- will hold all fields in the table.</dd>
- <dt>conditional</dt>
- <dd>This model is similar to the hierarchical model except that a seperate
- class will not be generated if that seperate class would only contain
- one field. So if a table has only one primary key field, that field
- will be merged into the base record class.</dd>
</dl>
-<p>Model types can be specified as a default for an entire context, and you can
-also override the default for each table in a context.
-See the
+<p>Model types can be specified as a default for an entire context, and you may
+override the default for each table in a context. See the
<a href="configreference/abatorContext.html"><abatorContext></a> reference page for
more information about setting the context default..
See the <a href="configreference/table.html"><table></a>
@@ -107,6 +108,11 @@
XML configuration.
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>
</ul>
</body>
</html>
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/DAOGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/DAOGenerator.java?rev=429494&r1=429493&r2=429494&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/DAOGenerator.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/DAOGenerator.java Mon Aug 7 15:06:23 2006
@@ -26,16 +26,26 @@
*/
public interface DAOGenerator {
/**
- * Sets unique properties for this instance. The properties consist of the
- * default properties for the DAOGenerator, overridden and added to by any
- * DAOGenerator properties that are unique to the current table.
+ * Adds properties for this instance from any properties configured
+ * in the DAOGeneratorConfiguration.
*
* This method will be called before any of the get methods.
*
* @param properties
* All properties from the configuration
*/
- void setProperties(Map properties);
+ void addConfigurationProperties(Map properties);
+
+ /**
+ * Adds properties for this instance from any properties configured
+ * in the current context.
+ *
+ * This method will be called before any of the get methods.
+ *
+ * @param properties
+ * All properties from the configuration
+ */
+ void addContextProperties(Map properties);
/**
* Abator will supply a list to this method. The implementation class may
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/JavaModelGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/JavaModelGenerator.java?rev=429494&r1=429493&r2=429494&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/JavaModelGenerator.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/JavaModelGenerator.java Mon Aug 7 15:06:23 2006
@@ -36,15 +36,28 @@
*/
public interface JavaModelGenerator {
- /**
- * Sets the properties of the generator taken from the
- * JavaModelGeneratorConfiguration element. This method is
- * called before any getXXX method.
- *
- * @param properties the configuration element's properties
- */
- void setProperties(Map properties);
-
+ /**
+ * Adds properties for this instance from any properties configured
+ * in the JavaModelGeneratorConfiguration.
+ *
+ * This method will be called before any of the get methods.
+ *
+ * @param properties
+ * All properties from the configuration
+ */
+ void addConfigurationProperties(Map properties);
+
+ /**
+ * Adds properties for this instance from any properties configured
+ * in the current context.
+ *
+ * This method will be called before any of the get methods.
+ *
+ * @param properties
+ * All properties from the configuration
+ */
+ void addContextProperties(Map properties);
+
/**
* Abator will supply a list to this method. The implementation class may
* add strings to the list that will be treated as warning messages and
@@ -115,13 +128,4 @@
* @return a list of GeneratedJavaFile objects
*/
List getGeneratedJavaFiles(IntrospectedTable introspectedTable, ProgressCallback callback);
-
- /**
- * Returns the value of a set property, or null if the
- * property is not set.
- *
- * @param key
- * @return the property value
- */
- String getProperty(String key);
}
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/JavaTypeResolver.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/JavaTypeResolver.java?rev=429494&r1=429493&r2=429494&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/JavaTypeResolver.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/JavaTypeResolver.java Mon Aug 7 15:06:23 2006
@@ -30,7 +30,27 @@
* @author Jeff Butler
*/
public interface JavaTypeResolver {
- void setProperties(Map properties);
+ /**
+ * Adds properties for this instance from any properties configured
+ * in the JavaTypeResolverConfiguration.
+ *
+ * This method will be called before any of the get methods.
+ *
+ * @param properties
+ * All properties from the configuration
+ */
+ void addConfigurationProperties(Map properties);
+
+ /**
+ * Adds properties for this instance from any properties configured
+ * in the current context.
+ *
+ * This method will be called before any of the get methods.
+ *
+ * @param properties
+ * All properties from the configuration
+ */
+ void addContextProperties(Map properties);
/**
* Abator will supply a list to this method. The implementation class may
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/SqlMapGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/SqlMapGenerator.java?rev=429494&r1=429493&r2=429494&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/SqlMapGenerator.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/SqlMapGenerator.java Mon Aug 7 15:06:23 2006
@@ -38,7 +38,27 @@
*/
void setWarnings(List warnings);
- void setProperties(Map properties);
+ /**
+ * Adds properties for this instance from any properties configured
+ * in the SqlMapGeneratorConfiguration.
+ *
+ * This method will be called before any of the get methods.
+ *
+ * @param properties
+ * All properties from the configuration
+ */
+ void addConfigurationProperties(Map properties);
+
+ /**
+ * Adds properties for this instance from any properties configured
+ * in the current context.
+ *
+ * This method will be called before any of the get methods.
+ *
+ * @param properties
+ * All properties from the configuration
+ */
+ void addContextProperties(Map properties);
void setTargetPackage(String targetPackage);
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/dom/java/JavaElement.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/dom/java/JavaElement.java?rev=429494&r1=429493&r2=429494&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/dom/java/JavaElement.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/dom/java/JavaElement.java Mon Aug 7 15:06:23 2006
@@ -104,4 +104,8 @@
public void setVisibility(JavaVisibility visibility) {
this.visibility = visibility;
}
+
+ public void addSuppressTypeWarningsAnnotation() {
+ addAnnotation("@SuppressWarnings(\"unchecked\")"); //$NON-NLS-1$
+ }
}
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/AbatorContext.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/AbatorContext.java?rev=429494&r1=429493&r2=429494&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/AbatorContext.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/AbatorContext.java Mon Aug 7 15:06:23 2006
@@ -39,7 +39,7 @@
/**
* @author Jeff Butler
*/
-public class AbatorContext {
+public class AbatorContext extends PropertyHolder {
private String id;
private JDBCConnectionConfiguration jdbcConnectionConfiguration;
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/ModelType.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/ModelType.java?rev=429494&r1=429493&r2=429494&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/ModelType.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/ModelType.java Mon Aug 7 15:06:23 2006
@@ -16,6 +16,8 @@
package org.apache.ibatis.abator.config;
+import org.apache.ibatis.abator.internal.util.messages.Messages;
+
/**
* Typesafe enum of different model types
*
@@ -48,7 +50,7 @@
} else if (CONDITIONAL.getModelType().equalsIgnoreCase(type)) {
return CONDITIONAL;
} else {
- throw new RuntimeException("Invalid model type: " + type);
+ throw new RuntimeException(Messages.getString("RuntimeError.13", type)); //$NON-NLS-1$
}
}
}
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=429494&r1=429493&r2=429494&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 Mon Aug 7 15:06:23 2006
@@ -191,7 +191,9 @@
continue;
}
- if ("jdbcConnection".equals(childNode.getNodeName())) { //$NON-NLS-1$
+ if ("property".equals(childNode.getNodeName())) { //$NON-NLS-1$
+ parseProperty(abatorContext, childNode);
+ } else if ("jdbcConnection".equals(childNode.getNodeName())) { //$NON-NLS-1$
parseJdbcConnection(abatorContext, childNode);
} else if ("javaModelGenerator".equals(childNode.getNodeName())) { //$NON-NLS-1$
parseJavaModelGenerator(abatorContext, childNode);
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=429494&r1=429493&r2=429494&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 Mon Aug 7 15:06:23 2006
@@ -18,8 +18,17 @@
<!--
This DTD defines the structure of the Abator for iBATIS configuration file.
+ Abator configuration files should declare the DOCTYPE as follows:
+
+ <!DOCTYPE abatorConfiguration PUBLIC
+ "-//Apache Software Foundation//DTD Abator for iBATIS Configuration 1.0//EN"
+ "http://ibatis.apache.org/dtd/abator-config_1_0.dtd">
+
Please see the documentation included with Abator for details on each option
- in the DTD.
+ in the DTD. You may also view documentation on-line here:
+
+ http://ibatis.apache.org/docs/tools/abator
+
-->
<!ENTITY % Boolean "(true|false)">
@@ -34,7 +43,7 @@
The abatorContext element is used to describe a context for generating files, and the source
tables.
-->
-<!ELEMENT abatorContext (jdbcConnection, javaTypeResolver?, javaModelGenerator,
+<!ELEMENT abatorContext (property*, jdbcConnection, javaTypeResolver?, javaModelGenerator,
sqlMapGenerator, daoGenerator?, table+)>
<!ATTLIST abatorContext id CDATA #IMPLIED
defaultModelType %ModelType; #IMPLIED
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/AbatorObjectFactory.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/AbatorObjectFactory.java?rev=429494&r1=429493&r2=429494&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/AbatorObjectFactory.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/AbatorObjectFactory.java Mon Aug 7 15:06:23 2006
@@ -15,7 +15,6 @@
*/
package org.apache.ibatis.abator.internal;
-import java.util.HashMap;
import java.util.List;
import org.apache.ibatis.abator.api.DAOGenerator;
@@ -84,11 +83,11 @@
JavaTypeResolver answer = (JavaTypeResolver) createObject(type);
answer.setWarnings(warnings);
- if (config == null) {
- answer.setProperties(new HashMap());
- } else {
- answer.setProperties(config.getProperties());
+ if (config != null) {
+ answer.addConfigurationProperties(config.getProperties());
}
+
+ answer.addContextProperties(context.getProperties());
return answer;
}
@@ -109,7 +108,8 @@
answer.setWarnings(warnings);
answer.setJavaModelGenerator(javaModelGenerator);
- answer.setProperties(config.getProperties());
+ answer.addConfigurationProperties(config.getProperties());
+ answer.addContextProperties(context.getProperties());
answer.setTargetPackage(config.getTargetPackage());
answer.setTargetProject(config.getTargetProject());
@@ -131,7 +131,8 @@
JavaModelGenerator answer = (JavaModelGenerator) createObject(type);
answer.setWarnings(warnings);
- answer.setProperties(config.getProperties());
+ answer.addConfigurationProperties(config.getProperties());
+ answer.addContextProperties(context.getProperties());
answer.setTargetPackage(config.getTargetPackage());
answer.setTargetProject(config.getTargetProject());
@@ -153,7 +154,8 @@
answer.setWarnings(warnings);
answer.setJavaModelGenerator(javaModelGenerator);
- answer.setProperties(config.getProperties());
+ answer.addConfigurationProperties(config.getProperties());
+ answer.addContextProperties(context.getProperties());
answer.setSqlMapGenerator(sqlMapGenerator);
answer.setTargetPackage(config.getTargetPackage());
answer.setTargetProject(config.getTargetProject());
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/DefaultDAOMethodNameCalculator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/DefaultDAOMethodNameCalculator.java?rev=429494&r1=429493&r2=429494&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/DefaultDAOMethodNameCalculator.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/DefaultDAOMethodNameCalculator.java Mon Aug 7 15:06:23 2006
@@ -18,6 +18,7 @@
import org.apache.ibatis.abator.api.DAOMethodNameCalculator;
import org.apache.ibatis.abator.api.IntrospectedTable;
+import org.apache.ibatis.abator.internal.rules.AbatorRules;
/**
* @author Jeff Butler
@@ -36,18 +37,40 @@
return "insert"; //$NON-NLS-1$
}
+ /**
+ * 1. if this will be the only updateByPrimaryKey, then the
+ * result should be updateByPrimaryKey.
+ * 2. If the other method is enabled, but there are seperate
+ * base and blob classes, then the method name should be
+ * updateByPrimaryKey
+ * 3. Else the method name should be updateByPrimaryKeyWithoutBLOBs
+ */
public String getUpdateByPrimaryKeyWithoutBLOBsMethodName(IntrospectedTable introspectedTable) {
- if (introspectedTable.getRules().generateUpdateByPrimaryKeyWithBLOBs()
- && !introspectedTable.getRules().generateRecordWithBLOBsClass()) {
- // can't use the same method name for both methods...
- return "updateByPrimaryKeyWithoutBLOBs"; //$NON-NLS-1$
- } else {
+ AbatorRules rules = introspectedTable.getRules();
+
+ if (!rules.generateUpdateByPrimaryKeyWithBLOBs()) {
+ return "updateByPrimaryKey"; //$NON-NLS-1$
+ } else if (rules.generateRecordWithBLOBsClass()) {
return "updateByPrimaryKey"; //$NON-NLS-1$
+ } else {
+ return "updateByPrimaryKeyWithoutBLOBs"; //$NON-NLS-1$
}
}
+ /**
+ * 1. if this will be the only updateByPrimaryKey, then the
+ * result should be updateByPrimaryKey.
+ * 2. If the other method is enabled, but there are seperate
+ * base and blob classes, then the method name should be
+ * updateByPrimaryKey
+ * 3. Else the method name should be updateByPrimaryKeyWithBLOBs
+ */
public String getUpdateByPrimaryKeyWithBLOBsMethodName(IntrospectedTable introspectedTable) {
- if (introspectedTable.getRules().generateRecordWithBLOBsClass()) {
+ AbatorRules rules = introspectedTable.getRules();
+
+ if (!rules.generateUpdateByPrimaryKeyWithoutBLOBs()) {
+ return "updateByPrimaryKey"; //$NON-NLS-1$
+ } else if (rules.generateRecordWithBLOBsClass()) {
return "updateByPrimaryKey"; //$NON-NLS-1$
} else {
return "updateByPrimaryKeyWithBLOBs"; //$NON-NLS-1$
@@ -62,12 +85,34 @@
return "deleteByPrimaryKey"; //$NON-NLS-1$
}
+ /**
+ * 1. if this will be the only selectByExample, then the
+ * result should be selectByExample.
+ * 2. Else the method name should be selectByExampleWithoutBLOBs
+ */
public String getSelectByExampleWithoutBLOBsMethodName(IntrospectedTable introspectedTable) {
- return "selectByExample"; //$NON-NLS-1$
+ AbatorRules rules = introspectedTable.getRules();
+
+ if (!rules.generateSelectByExampleWithBLOBs()) {
+ return "selectByExample"; //$NON-NLS-1$
+ } else {
+ return "selectByExampleWithoutBLOBs"; //$NON-NLS-1$
+ }
}
+ /**
+ * 1. if this will be the only selectByExample, then the
+ * result should be selectByExample.
+ * 2. Else the method name should be selectByExampleWithBLOBs
+ */
public String getSelectByExampleWithBLOBsMethodName(IntrospectedTable introspectedTable) {
- return "selectByExampleWithBLOBs"; //$NON-NLS-1$
+ AbatorRules rules = introspectedTable.getRules();
+
+ if (!rules.generateSelectByExampleWithoutBLOBs()) {
+ return "selectByExample"; //$NON-NLS-1$
+ } else {
+ return "selectByExampleWithBLOBs"; //$NON-NLS-1$
+ }
}
public String getSelectByPrimaryKeyMethodName(IntrospectedTable introspectedTable) {
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/ExtendedDAOMethodNameCalculator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/ExtendedDAOMethodNameCalculator.java?rev=429494&r1=429493&r2=429494&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/ExtendedDAOMethodNameCalculator.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/ExtendedDAOMethodNameCalculator.java Mon Aug 7 15:06:23 2006
@@ -18,6 +18,7 @@
import org.apache.ibatis.abator.api.DAOMethodNameCalculator;
import org.apache.ibatis.abator.api.IntrospectedTable;
+import org.apache.ibatis.abator.internal.rules.AbatorRules;
/**
* @author Jeff Butler
@@ -40,29 +41,51 @@
return sb.toString();
}
+ /**
+ * 1. if this will be the only updateByPrimaryKey, then the
+ * result should be updateByPrimaryKey.
+ * 2. If the other method is enabled, but there are seperate
+ * base and blob classes, then the method name should be
+ * updateByPrimaryKey
+ * 3. Else the method name should be updateByPrimaryKeyWithoutBLOBs
+ */
public String getUpdateByPrimaryKeyWithoutBLOBsMethodName(IntrospectedTable introspectedTable) {
StringBuffer sb = new StringBuffer();
sb.append("update"); //$NON-NLS-1$
sb.append(introspectedTable.getTable().getDomainObjectName());
- if (introspectedTable.getRules().generateUpdateByPrimaryKeyWithBLOBs()
- && !introspectedTable.getRules().generateRecordWithBLOBsClass()) {
- // can't use the same method name for both methods...
- sb.append("ByPrimaryKeyWithoutBLOBs"); //$NON-NLS-1$
- } else {
+ AbatorRules rules = introspectedTable.getRules();
+
+ if (!rules.generateUpdateByPrimaryKeyWithBLOBs()) {
+ sb.append("ByPrimaryKey"); //$NON-NLS-1$
+ } else if (rules.generateRecordWithBLOBsClass()) {
sb.append("ByPrimaryKey"); //$NON-NLS-1$
+ } else {
+ sb.append("ByPrimaryKeyWithoutBLOBs"); //$NON-NLS-1$
}
return sb.toString();
}
+ /**
+ * 1. if this will be the only updateByPrimaryKey, then the
+ * result should be updateByPrimaryKey.
+ * 2. If the other method is enabled, but there are seperate
+ * base and blob classes, then the method name should be
+ * updateByPrimaryKey
+ * 3. Else the method name should be updateByPrimaryKeyWithBLOBs
+ */
public String getUpdateByPrimaryKeyWithBLOBsMethodName(IntrospectedTable introspectedTable) {
StringBuffer sb = new StringBuffer();
sb.append("update"); //$NON-NLS-1$
sb.append(introspectedTable.getTable().getDomainObjectName());
- if (introspectedTable.getRules().generateRecordWithBLOBsClass()) {
+ AbatorRules rules = introspectedTable.getRules();
+
+ if (!rules.generateUpdateByPrimaryKeyWithoutBLOBs()) {
+ sb.append("ByPrimaryKey"); //$NON-NLS-1$
+ } else if (rules.generateRecordWithBLOBsClass()) {
sb.append("ByPrimaryKey"); //$NON-NLS-1$
} else {
sb.append("ByPrimaryKeyWithBLOBs"); //$NON-NLS-1$
@@ -89,20 +112,42 @@
return sb.toString();
}
+ /**
+ * 1. if this will be the only selectByExample, then the
+ * result should be selectByExample.
+ * 2. Else the method name should be selectByExampleWithoutBLOBs
+ */
public String getSelectByExampleWithoutBLOBsMethodName(IntrospectedTable introspectedTable) {
StringBuffer sb = new StringBuffer();
sb.append("select"); //$NON-NLS-1$
sb.append(introspectedTable.getTable().getDomainObjectName());
sb.append("ByExample"); //$NON-NLS-1$
+ AbatorRules rules = introspectedTable.getRules();
+
+ if (rules.generateSelectByExampleWithBLOBs()) {
+ sb.append("WithoutBLOBs"); //$NON-NLS-1$
+ }
+
return sb.toString();
}
+ /**
+ * 1. if this will be the only selectByExample, then the
+ * result should be selectByExample.
+ * 2. Else the method name should be selectByExampleWithBLOBs
+ */
public String getSelectByExampleWithBLOBsMethodName(IntrospectedTable introspectedTable) {
StringBuffer sb = new StringBuffer();
sb.append("select"); //$NON-NLS-1$
sb.append(introspectedTable.getTable().getDomainObjectName());
- sb.append("ByExampleWithBLOBs"); //$NON-NLS-1$
+ sb.append("ByExample"); //$NON-NLS-1$
+
+ AbatorRules rules = introspectedTable.getRules();
+
+ if (rules.generateSelectByExampleWithoutBLOBs()) {
+ sb.append("WithBLOBs"); //$NON-NLS-1$
+ }
return sb.toString();
}
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=429494&r1=429493&r2=429494&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 Mon Aug 7 15:06:23 2006
@@ -94,9 +94,17 @@
String tableName = rs.getString("TABLE_NAME"); //$NON-NLS-1$
String catalog = rs.getString("TABLE_CAT"); //$NON-NLS-1$
String schema = rs.getString("TABLE_SCHEM"); //$NON-NLS-1$
-
- String fullyQualifiedTableName = StringUtility.composeFullyQualifiedTableName(catalog, schema, tableName);
+ // we only use the returned catalog and schema if something was actually
+ // specified on the table configuration. If something was returned
+ // from the DB for these fields, but nothing was specified on the table
+ // configuration, then some sort of DB default is being returned
+ // and we don't want that in our SQL
+ FullyQualifiedTable table = new FullyQualifiedTable(
+ StringUtility.stringHasValue(tc.getCatalog()) ? catalog : null,
+ StringUtility.stringHasValue(tc.getSchema()) ? schema : null,
+ tableName, tc.getDomainObjectName(), tc.getAlias());
+
ColumnOverride columnOverride = tc.getColumnOverride(cd
.getColumnName());
@@ -120,8 +128,8 @@
// if the type is not supported, then we'll report a warning and
// ignore the column
warnings.add(Messages.getString("Warning.14", //$NON-NLS-1$
- fullyQualifiedTableName, cd
- .getColumnName()));
+ table.getFullyQualifiedTableName(),
+ cd.getColumnName()));
continue;
}
@@ -158,12 +166,10 @@
if (!tc.isColumnIgnored(cd.getColumnName())) {
IntrospectedTableImpl introspectedTable =
- (IntrospectedTableImpl) introspectedTables.get(fullyQualifiedTableName);
+ (IntrospectedTableImpl) introspectedTables.get(table.getFullyQualifiedTableName());
if (introspectedTable == null) {
- FullyQualifiedTable table = new FullyQualifiedTable(catalog,
- schema, tableName, tc.getDomainObjectName(), tc.getAlias());
introspectedTable = new IntrospectedTableImpl(tc, new ColumnDefinitions(), table);
- introspectedTables.put(fullyQualifiedTableName, introspectedTable);
+ introspectedTables.put(table.getFullyQualifiedTableName(), introspectedTable);
}
introspectedTable.getColumnDefinitions().addColumn(cd);
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/BaseDAOGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/BaseDAOGenerator.java?rev=429494&r1=429493&r2=429494&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/BaseDAOGenerator.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/BaseDAOGenerator.java Mon Aug 7 15:06:23 2006
@@ -55,7 +55,7 @@
* <dl>
* <dt>enableSubPackages</dt>
* <dd>If true, the classes will be generated in sub-packaged based on the
- * database catalg and schema - else the will be generated in the specified
+ * database catalog and schema - else the will be generated in the specified
* package (the targetPackage attribute). Default is false.</dd>
*
* <dt>rootInterface</dt>
@@ -104,7 +104,7 @@
private Map tableValueMaps;
private boolean useJava5Features;
-
+
protected JavaVisibility exampleMethodVisibility = JavaVisibility.PUBLIC;
protected DAOMethodNameCalculator methodNameCalculator = new DefaultDAOMethodNameCalculator();
@@ -118,15 +118,12 @@
this.daoTemplate = daoTemplate;
this.useJava5Features = useJava5Features;
tableValueMaps = new HashMap();
+ properties = new HashMap();
}
- /*
- * (non-Javadoc)
- *
- * @see org.apache.ibatis.abator.api.DAOGenerator#setProperties(java.util.Map)
- */
- public void setProperties(Map properties) {
- this.properties = properties;
+ public void addConfigurationProperties(Map properties) {
+ this.properties.putAll(properties);
+
if (properties.containsKey("exampleMethodVisibility")) { //$NON-NLS-1$
String value = (String) properties.get("exampleMethodVisibility"); //$NON-NLS-1$
@@ -729,7 +726,7 @@
StringBuffer sb = new StringBuffer();
if (useJava5Features) {
- method.addAnnotation("@SuppressWarnings(\"unchecked\")"); //$NON-NLS-1$
+ method.addSuppressTypeWarningsAnnotation();
sb.append(returnType.getShortName());
sb.append(" list = ("); //$NON-NLS-1$
sb.append(returnType.getShortName());
@@ -803,7 +800,7 @@
StringBuffer sb = new StringBuffer();
if (useJava5Features) {
- method.addAnnotation("@SuppressWarnings(\"unchecked\")"); //$NON-NLS-1$
+ method.addSuppressTypeWarningsAnnotation();
sb.append(returnType.getShortName());
sb.append(" list = ("); //$NON-NLS-1$
sb.append(returnType.getShortName());
@@ -875,20 +872,20 @@
sb.setLength(0);
sb.append(keyType.getShortName());
- sb.append(" key = new ");
+ sb.append(" key = new "); //$NON-NLS-1$
sb.append(keyType.getShortName());
- sb.append("();");
+ sb.append("();"); //$NON-NLS-1$
method.addBodyLine(sb.toString());
iter = introspectedTable.getPrimaryKeyColumns();
while (iter.hasNext()) {
ColumnDefinition cd = (ColumnDefinition) iter.next();
sb.setLength(0);
- sb.append("key.");
+ sb.append("key."); //$NON-NLS-1$
sb.append(JavaBeansUtil.getSetterMethodName(cd.getJavaProperty()));
sb.append('(');
sb.append(cd.getJavaProperty());
- sb.append(");");
+ sb.append(");"); //$NON-NLS-1$
method.addBodyLine(sb.toString());
}
}
@@ -1000,20 +997,20 @@
sb.setLength(0);
sb.append(keyType.getShortName());
- sb.append(" key = new ");
+ sb.append(" key = new "); //$NON-NLS-1$
sb.append(keyType.getShortName());
- sb.append("();");
+ sb.append("();"); //$NON-NLS-1$
method.addBodyLine(sb.toString());
iter = introspectedTable.getPrimaryKeyColumns();
while (iter.hasNext()) {
ColumnDefinition cd = (ColumnDefinition) iter.next();
sb.setLength(0);
- sb.append("key.");
+ sb.append("key."); //$NON-NLS-1$
sb.append(JavaBeansUtil.getSetterMethodName(cd.getJavaProperty()));
sb.append('(');
sb.append(cd.getJavaProperty());
- sb.append(");");
+ sb.append(");"); //$NON-NLS-1$
method.addBodyLine(sb.toString());
}
}
@@ -1088,5 +1085,9 @@
}
return map;
+ }
+
+ public void addContextProperties(Map properties) {
+ this.properties.putAll(properties);
}
}
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/BaseLegacyDAOGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/BaseLegacyDAOGenerator.java?rev=429494&r1=429493&r2=429494&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/BaseLegacyDAOGenerator.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/BaseLegacyDAOGenerator.java Mon Aug 7 15:06:23 2006
@@ -19,6 +19,7 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import org.apache.ibatis.abator.api.DAOGenerator;
import org.apache.ibatis.abator.api.FullyQualifiedTable;
@@ -42,6 +43,8 @@
*
*/
public class BaseLegacyDAOGenerator extends BaseDAOGenerator implements DAOGenerator {
+
+ private boolean suppressTypeWarnings;
/**
*
@@ -68,7 +71,7 @@
method1.addComment(table);
method1.setVisibility(exampleMethodVisibility);
method1.setReturnType(FullyQualifiedJavaType.getNewListInstance());
- method1.setName("selectByExample"); //$NON-NLS-1$
+ method1.setName(methodNameCalculator.getSelectByExampleWithoutBLOBsMethodName(introspectedTable));
method1.addParameter(new Parameter(type, "example")); //$NON-NLS-1$
method1.addParameter(new Parameter(FullyQualifiedJavaType.getStringInstance(),
"orderByClause")); //$NON-NLS-1$
@@ -77,7 +80,7 @@
method2.addComment(table);
method2.setVisibility(JavaVisibility.PUBLIC);
method2.setReturnType(FullyQualifiedJavaType.getNewListInstance());
- method2.setName("selectByExample"); //$NON-NLS-1$
+ method2.setName(methodNameCalculator.getSelectByExampleWithoutBLOBsMethodName(introspectedTable));
method2.addParameter(new Parameter(type, "example")); //$NON-NLS-1$
Iterator iter = daoTemplate.getCheckedExceptions().iterator();
@@ -94,6 +97,9 @@
StringBuffer sb = new StringBuffer();
+ if (suppressTypeWarnings) {
+ method1.addSuppressTypeWarningsAnnotation();
+ }
method1.addBodyLine("Map parms = getExampleParms(example);"); //$NON-NLS-1$
method1.addBodyLine("if (orderByClause != null) {"); //$NON-NLS-1$
method1.addBodyLine("parms.put(\"ABATOR_ORDER_BY_CLAUSE\", orderByClause);"); //$NON-NLS-1$
@@ -106,7 +112,12 @@
method1.addBodyLine(sb.toString());
method1.addBodyLine("return list;"); //$NON-NLS-1$
- method2.addBodyLine("return selectByExample(example, null);"); //$NON-NLS-1$
+
+ sb.setLength(0);
+ sb.append("return "); //$NON-NLS-1$
+ sb.append(methodNameCalculator.getSelectByExampleWithoutBLOBsMethodName(introspectedTable));
+ sb.append("(example, null);"); //$NON-NLS-1$
+ method2.addBodyLine(sb.toString());
}
ArrayList answer = new ArrayList();
@@ -134,7 +145,7 @@
method1.addComment(table);
method1.setVisibility(exampleMethodVisibility);
method1.setReturnType(FullyQualifiedJavaType.getNewListInstance());
- method1.setName("selectByExampleWithBLOBs"); //$NON-NLS-1$
+ method1.setName(methodNameCalculator.getSelectByExampleWithBLOBsMethodName(introspectedTable));
method1.addParameter(new Parameter(type, "example")); //$NON-NLS-1$
method1.addParameter(new Parameter(FullyQualifiedJavaType.getStringInstance(),
"orderByClause")); //$NON-NLS-1$
@@ -143,7 +154,7 @@
method2.addComment(table);
method2.setVisibility(JavaVisibility.PUBLIC);
method2.setReturnType(FullyQualifiedJavaType.getNewListInstance());
- method2.setName("selectByExampleWithBLOBs"); //$NON-NLS-1$
+ method2.setName(methodNameCalculator.getSelectByExampleWithBLOBsMethodName(introspectedTable));
method2.addParameter(new Parameter(type, "example")); //$NON-NLS-1$
Iterator iter = daoTemplate.getCheckedExceptions().iterator();
@@ -160,6 +171,9 @@
StringBuffer sb = new StringBuffer();
+ if (suppressTypeWarnings) {
+ method1.addSuppressTypeWarningsAnnotation();
+ }
method1.addBodyLine("Map parms = getExampleParms(example);"); //$NON-NLS-1$
method1.addBodyLine("if (orderByClause != null) {"); //$NON-NLS-1$
method1.addBodyLine("parms.put(\"ABATOR_ORDER_BY_CLAUSE\", orderByClause);"); //$NON-NLS-1$
@@ -172,7 +186,11 @@
method1.addBodyLine(sb.toString());
method1.addBodyLine("return list;"); //$NON-NLS-1$
- method2.addBodyLine("return selectByExampleWithBLOBs(example, null);"); //$NON-NLS-1$
+ sb.setLength(0);
+ sb.append("return "); //$NON-NLS-1$
+ sb.append(methodNameCalculator.getSelectByExampleWithBLOBsMethodName(introspectedTable));
+ sb.append("(example, null);"); //$NON-NLS-1$
+ method2.addBodyLine(sb.toString());
}
ArrayList answer = new ArrayList();
@@ -248,6 +266,9 @@
Method method = new Method();
method.addComment(table);
method.setVisibility(JavaVisibility.PRIVATE);
+ if (suppressTypeWarnings) {
+ method.addSuppressTypeWarningsAnnotation();
+ }
method.setReturnType(FullyQualifiedJavaType.getNewMapInstance());
method.setName("getExampleParms"); //$NON-NLS-1$
method.addParameter(new Parameter(type, "example")); //$NON-NLS-1$
@@ -309,6 +330,9 @@
Method method = new Method();
method.addComment(table);
method.setVisibility(JavaVisibility.PRIVATE);
+ if (suppressTypeWarnings) {
+ method.addSuppressTypeWarningsAnnotation();
+ }
method.setReturnType(FullyQualifiedJavaType.getNewMapInstance());
sb.append("get"); //$NON-NLS-1$
sb.append(cd.getColumnName());
@@ -396,5 +420,14 @@
method.addBodyLine("return parms;"); //$NON-NLS-1$
return method;
+ }
+
+ public void addContextProperties(Map properties) {
+ super.addContextProperties(properties);
+
+ if ("true".equalsIgnoreCase //$NON-NLS-1$
+ ((String) properties.get("suppressTypeWarnings"))) { //$NON-NLS-1$
+ suppressTypeWarnings = true;
+ }
}
}
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/model/JavaModelGeneratorJava2Impl.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/model/JavaModelGeneratorJava2Impl.java?rev=429494&r1=429493&r2=429494&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/model/JavaModelGeneratorJava2Impl.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/model/JavaModelGeneratorJava2Impl.java Mon Aug 7 15:06:23 2006
@@ -87,18 +87,29 @@
private Map tableValueMaps;
+ /**
+ * if true, then the annotation to suppress type warnings will be
+ * added to the appropriate methods
+ */
+ private boolean suppressTypeWarnings;
+
public JavaModelGeneratorJava2Impl() {
super();
tableValueMaps = new HashMap();
+ properties = new HashMap();
}
- /*
- * (non-Javadoc)
- *
- * @see org.apache.ibatis.abator.api.JavaModelGenerator#setProperties(java.util.Map)
- */
- public void setProperties(Map properties) {
- this.properties = properties;
+ public void addConfigurationProperties(Map properties) {
+ this.properties.putAll(properties);
+ }
+
+ public void addContextProperties(Map properties) {
+ this.properties.putAll(properties);
+
+ if ("true".equalsIgnoreCase //$NON-NLS-1$
+ ((String) properties.get("suppressTypeWarnings"))) { //$NON-NLS-1$
+ suppressTypeWarnings = true;
+ }
}
/*
@@ -562,6 +573,11 @@
protected Method getNoValueMethod(ColumnDefinition cd, String nameFragment, String operator) {
Method method = new Method();
method.setVisibility(JavaVisibility.PUBLIC);
+ if (!(this instanceof JavaModelGeneratorJava5Impl)) {
+ if (suppressTypeWarnings) {
+ method.addSuppressTypeWarningsAnnotation();
+ }
+ }
StringBuffer sb = new StringBuffer();
sb.append(cd.getJavaProperty());
sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
@@ -695,6 +711,9 @@
method = new Method();
method.addComment(table);
method.setVisibility(JavaVisibility.PUBLIC);
+ if (suppressTypeWarnings) {
+ method.addSuppressTypeWarningsAnnotation();
+ }
method.setName("or"); //$NON-NLS-1$
method.addParameter(new Parameter(FullyQualifiedJavaType.getCriteriaInstance(),
"criteria")); //$NON-NLS-1$
@@ -705,6 +724,9 @@
method = new Method();
method.addComment(table);
method.setVisibility(JavaVisibility.PUBLIC);
+ if (suppressTypeWarnings) {
+ method.addSuppressTypeWarningsAnnotation();
+ }
method.setName("createCriteria"); //$NON-NLS-1$
method.setReturnType(FullyQualifiedJavaType.getCriteriaInstance());
method.addBodyLine("Criteria criteria = new Criteria();"); //$NON-NLS-1$
@@ -826,6 +848,9 @@
// now add the methods for simplifying the individual field set methods
method = new Method();
method.setVisibility(JavaVisibility.PRIVATE);
+ if (suppressTypeWarnings) {
+ method.addSuppressTypeWarningsAnnotation();
+ }
method.setName("addCriterion"); //$NON-NLS-1$
method.addParameter(new Parameter(FullyQualifiedJavaType
.getStringInstance(), "condition")); //$NON-NLS-1$
@@ -849,6 +874,9 @@
method = new Method();
method.setVisibility(JavaVisibility.PRIVATE);
+ if (suppressTypeWarnings) {
+ method.addSuppressTypeWarningsAnnotation();
+ }
method.setName("addCriterion"); //$NON-NLS-1$
method.addParameter(new Parameter(FullyQualifiedJavaType
.getStringInstance(), "condition")); //$NON-NLS-1$
@@ -868,6 +896,9 @@
method = new Method();
method.setVisibility(JavaVisibility.PRIVATE);
+ if (suppressTypeWarnings) {
+ method.addSuppressTypeWarningsAnnotation();
+ }
method.setName("addCriterion"); //$NON-NLS-1$
method.addParameter(new Parameter(FullyQualifiedJavaType
.getStringInstance(), "condition")); //$NON-NLS-1$
@@ -914,6 +945,9 @@
method = new Method();
method.setVisibility(JavaVisibility.PRIVATE);
+ if (suppressTypeWarnings) {
+ method.addSuppressTypeWarningsAnnotation();
+ }
method.setName("addCriterionForJDBCDate"); //$NON-NLS-1$
method.addParameter(new Parameter(FullyQualifiedJavaType
.getStringInstance(), "condition")); //$NON-NLS-1$
@@ -975,6 +1009,9 @@
method = new Method();
method.setVisibility(JavaVisibility.PRIVATE);
+ if (suppressTypeWarnings) {
+ method.addSuppressTypeWarningsAnnotation();
+ }
method.setName("addCriterionForJDBCTime"); //$NON-NLS-1$
method.addParameter(new Parameter(FullyQualifiedJavaType
.getStringInstance(), "condition")); //$NON-NLS-1$
@@ -1289,9 +1326,5 @@
sb.append("CriteriaWithBetweenValue.add(map);"); //$NON-NLS-1$
method.addBodyLine(sb.toString());
innerClass.addMethod(method);
- }
-
- public String getProperty(String property) {
- return (String) properties.get(property);
}
}
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/rules/ConditionalModelRules.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/rules/ConditionalModelRules.java?rev=429494&r1=429493&r2=429494&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/rules/ConditionalModelRules.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/rules/ConditionalModelRules.java Mon Aug 7 15:06:23 2006
@@ -60,17 +60,23 @@
public boolean generateBaseRecordClass() {
return columnDefinitions.getBaseColumns().size() > 0
|| columnDefinitions.getPrimaryKeyColumns().size() == 1
- || columnDefinitions.getBaseColumns().size() == 1;
+ || (columnDefinitions.getBLOBColumns().size() > 0
+ && !generateRecordWithBLOBsClass());
}
/**
* We generate a record with BLOBs class if there is more than one
- * BLOB column.
+ * BLOB column. Do not generate a BLOBs class if any other
+ * super class would only contain one field
*
* @return true if the record with BLOBs class should be generated
*/
public boolean generateRecordWithBLOBsClass() {
- return columnDefinitions.getBLOBColumns().size() > 1;
+ int otherColumnCount = columnDefinitions.getPrimaryKeyColumns().size()
+ + columnDefinitions.getBaseColumns().size();
+
+ return otherColumnCount > 1
+ && columnDefinitions.getBLOBColumns().size() > 1;
}
}
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/sqlmap/SqlMapGeneratorIterateImpl.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/sqlmap/SqlMapGeneratorIterateImpl.java?rev=429494&r1=429493&r2=429494&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/sqlmap/SqlMapGeneratorIterateImpl.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/sqlmap/SqlMapGeneratorIterateImpl.java Mon Aug 7 15:06:23 2006
@@ -80,6 +80,7 @@
public SqlMapGeneratorIterateImpl() {
super();
tableStringMaps = new HashMap();
+ properties = new HashMap();
}
private Map getTableStringMap(FullyQualifiedTable table) {
@@ -92,13 +93,12 @@
return map;
}
- /*
- * (non-Javadoc)
- *
- * @see org.apache.ibatis.abator.api.SqlMapGenerator#setProperties(java.util.Map)
- */
- public void setProperties(Map properties) {
- this.properties = properties;
+ public void addConfigurationProperties(Map properties) {
+ this.properties.putAll(properties);
+ }
+
+ public void addContextProperties(Map properties) {
+ this.properties.putAll(properties);
}
/*
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/types/JavaTypeResolverDefaultImpl.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/types/JavaTypeResolverDefaultImpl.java?rev=429494&r1=429493&r2=429494&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/types/JavaTypeResolverDefaultImpl.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/types/JavaTypeResolverDefaultImpl.java Mon Aug 7 15:06:23 2006
@@ -18,6 +18,7 @@
import java.math.BigDecimal;
import java.sql.Types;
import java.util.Date;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -38,16 +39,16 @@
public JavaTypeResolverDefaultImpl() {
super();
+ properties = new HashMap();
}
- /*
- * (non-Javadoc)
- *
- * @see org.apache.ibatis.generator.api.types.JavaTypeResolver#setProperties(java.util.Map)
- */
- public void setProperties(Map properties) {
- this.properties = properties;
- }
+ public void addConfigurationProperties(Map properties) {
+ this.properties.putAll(properties);
+ }
+
+ public void addContextProperties(Map properties) {
+ this.properties.putAll(properties);
+ }
/*
* (non-Javadoc)
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/util/messages/messages.properties
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/util/messages/messages.properties?rev=429494&r1=429493&r2=429494&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/util/messages/messages.properties (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/util/messages/messages.properties Mon Aug 7 15:06:23 2006
@@ -25,6 +25,7 @@
RuntimeError.10=Internal Error - Unsupported Table Type
RuntimeError.11=Enumerations do not have super classes
RuntimeError.12=Internal Error - Cannot calculate record type for selectByExample method
+RuntimeError.13=Invalid model type: {0}
Warning.0=There are no statements enabled for table {0}, this table will be ignored.
Warning.1=Table {0} does not exist, this table will be ignored