Author: jgbutler Date: Tue Feb 5 11:24:41 2008 New Revision: 618753 URL: http://svn.apache.org/viewvc?rev=618753&view=rev Log: Abator: rootClass and rootInterface can be specified at the table level, misc. documentation updates
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/build/version.properties ibatis/trunk/java/mapper/mapper2/tools/abator/core/doc/ReleaseNotes.txt ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/daoGenerator.html ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/generatedKey.html ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/javaModelGenerator.html ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/table.html ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/running.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/GeneratedKey.java ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/PropertyRegistry.java 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/internal/java/dao/BaseDAOGenerator.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/sqlmap/SqlMapGeneratorIterateImpl.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/build/version.properties URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/build/version.properties?rev=618753&r1=618752&r2=618753&view=diff ============================================================================== --- ibatis/trunk/java/mapper/mapper2/tools/abator/core/build/version.properties (original) +++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/build/version.properties Tue Feb 5 11:24:41 2008 @@ -1,4 +1,4 @@ #Abator build version info -#Mon Jan 28 13:05:36 CST 2008 +#Tue Feb 05 12:11:25 CST 2008 version=1.1.0 -buildNum=401 +buildNum=402 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=618753&r1=618752&r2=618753&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 Tue Feb 5 11:24:41 2008 @@ -43,6 +43,9 @@ 16. IBATIS-470 - make legacy DAOs extendable 17. IBATIS-468 - add <columnRenamingRule> 18. Added DB2 Main Frame database dialect for generated keys +19. Allow rootClass and rootInterface to be specified at the table level +20. Allowed specifying a type (pre or post) for the generatedKey + element. ------------------------------------------------------------------------------- Version 1.0.0: Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/daoGenerator.html URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/daoGenerator.html?rev=618753&r1=618752&r2=618753&view=diff ============================================================================== --- ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/daoGenerator.html (original) +++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/daoGenerator.html Tue Feb 5 11:24:41 2008 @@ -176,7 +176,8 @@ <tr> <td valign="top">rootInterface</td> <td>This property can be used to specify a super interface for all generated - DAO interface objects. + DAO interface objects. This value may be overridden by specifying + the <code>rootInterface</code> property on a Table configuration. <p><b>Important:</b> Abator does not verify that the interface exists, or is a valid Java interface.</p> <p>If specified, the value of this property should be a fully qualified Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/generatedKey.html URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/generatedKey.html?rev=618753&r1=618752&r2=618753&view=diff ============================================================================== --- ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/generatedKey.html (original) +++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/generatedKey.html Tue Feb 5 11:24:41 2008 @@ -69,17 +69,34 @@ </table> </td> </tr> +</table> + +<h2>Optional Attributes</h2> +<table border="1" cellspacing="0" cellpadding="5"> + <tr> + <th>Attribute</th> + <th>Description</th> + </tr> <tr> - <td>identity</td> - <td>If <code>true</code>, then the generated <code><selectKey></code> element will be placed + <td valign="top">identity</td> + <td>If <code>true</code>, then the column is flagged as an identity column and the + generated <code><selectKey></code> element will be placed after the insert (for an identity column). If <code>false</code>, then the generated <code><selectKey></code> will be placed before the insert - (typically for a sequence).</td> + (typically for a sequence). + <p><b>Important:</b> Even if you specify the <code>type</code> attribute as "post", + you should still specify this value as "true" for identity columns. This will flag + Abator to remove the column from the insert list.</p> + <p>The default is <i>false</i>.</p></td> + </tr> + <tr> + <td valign="top">type</td> + <td>If specified, then this value will be added as the type of the generated <code><selectKey></code> element. + The value of this property should be either "pre" or "post". + <p><b>Important:</b> if a value is specified for this attribute, then the generated + <code><selectKey></code> element will always be placed before the insert statement.</p></td> </tr> </table> - -<h2>Optional Attributes</h2> -<p>None</p> <h2>Child Elements</h2> <p>None</p> Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/javaModelGenerator.html URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/javaModelGenerator.html?rev=618753&r1=618752&r2=618753&view=diff ============================================================================== --- ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/javaModelGenerator.html (original) +++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/javaModelGenerator.html Tue Feb 5 11:24:41 2008 @@ -96,7 +96,8 @@ <td>This property can be used to specify a root class for all generated Java model objects. Abator will specify this value as the super class of the primary key object, if the table has a primary key, or the - record object otherwise. + record object otherwise. This value may be overridden by specifying + the <code>rootClass</code> property on a Table configuration. <p><b>Important:</b> Abator does not verify that the class exists, or is a valid Java class. The generated classes may override elements in this class without warning.</p> 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=618753&r1=618752&r2=618753&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 Tue Feb 5 11:24:41 2008 @@ -281,6 +281,31 @@ <p><i>The default value is false.</i></p></td> </tr> <tr> + <td valign="top">rootClass</td> + <td>This property can be used to specify a root class for all generated + Java model objects. Abator will specify this value as the super class + of the primary key object, if the table has a primary key, or the + record object otherwise. The value specified in this property will override + the <code>rootClass</code> property set on the Java Model Generator + configuration if any is set. + <p><b>Important:</b> Abator does not verify that the class exists, or is a + valid Java class. The generated classes may override elements in this + class without warning.</p> + <p>If specified, the value of this property should be a fully qualified + class name (like com.mycompany.MyRootClass).</p></td> + </tr> + <tr> + <td valign="top">rootInterface</td> + <td>This property can be used to specify a super interface for all generated + DAO interface objects. The value specified in this property will override + the <code>rootInterface</code> property set on the DAO Generator + configuration if any is set. + <p><b>Important:</b> Abator does not verify that the interface exists, or is a + valid Java interface.</p> + <p>If specified, the value of this property should be a fully qualified + interface name (like com.mycompany.MyRootInterface).</p></td> + </tr> + <tr> <td valign="top">runtimeTableName</td> <td>If you specify a value for this property, than Abator will use that value as the table name in the generated SQL rather than the <code>tableName</code> Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/running.html URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/running.html?rev=618753&r1=618752&r2=618753&view=diff ============================================================================== --- ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/running.html (original) +++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/running.html Tue Feb 5 11:24:41 2008 @@ -178,6 +178,9 @@ accessed in the Abator configuration file with the escape sequence <code>${generated.source.dir}</code> </li> + <li>If a property is specified in the configuration file and is not resolved, + then the escaped property string will be passed "as is" into the generated code. + </li> </ul> <h2>Running Abator from Java with an XML Configuration File</h2> @@ -194,6 +197,21 @@ Abator abator = new Abator(config, callback, warnings); abator.generate(null); </pre> + +<p>Notes:</p> +<ul> + <li>Configuration file properties may be passed to the parser as a parameter on + the AbatorConfigurationParser constructor. If not passed explicitly, the JVM + system properties will be searched for the value of configuration file + properties. For example, the property + <code>generated.source.dir</code> can be + accessed in the Abator configuration file with the escape sequence + <code>${generated.source.dir}</code> + </li> + <li>If a property is specified in the configuration file and is not resolved, + then the escaped property string will be passed "as is" into the generated code. + </li> +</ul> <h2>Running Abator from Java with a Java Based Configuration</h2> <p>The following code sample shows how to call Abator from Java only. It does 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=618753&r1=618752&r2=618753&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 Tue Feb 5 11:24:41 2008 @@ -96,6 +96,12 @@ <li>Exposed new support for selecting tables and/or contexts to the command line and the Ant task - this has added an advanced syntax to the command line for Abator.</li> + <li><code>rootClass</code> and <code>rootInterface</code> may now be specified for each table. + See the <a href="configreference/table.html"><table></a> + reference page for more information.</li> + <li>Allowed specifying a type (pre or post) for the generated key element. See the + <a href="configreference/generatedKey.html"><generatedKey></a> + reference page for more information</li> </ul> <h2>Version 1.0.0</h2> Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/GeneratedKey.java URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/GeneratedKey.java?rev=618753&r1=618752&r2=618753&view=diff ============================================================================== --- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/GeneratedKey.java (original) +++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/GeneratedKey.java Tue Feb 5 11:24:41 2008 @@ -18,6 +18,7 @@ import org.apache.ibatis.abator.api.dom.xml.Attribute; import org.apache.ibatis.abator.api.dom.xml.XmlElement; import org.apache.ibatis.abator.internal.db.DatabaseDialects; +import org.apache.ibatis.abator.internal.util.StringUtility; /** * This class specifies that a key is auto-generated, either as an identity @@ -70,12 +71,27 @@ return type; } + public boolean isBeforeInsert() { + boolean rc; + if (StringUtility.stringHasValue(type)) { + rc = true; + } else { + if (isIdentity) { + rc = false; + } else { + rc = true; + } + } + + return rc; + } + public XmlElement toXmlElement() { XmlElement xmlElement = new XmlElement("generatedKey"); //$NON-NLS-1$ xmlElement.addAttribute(new Attribute("column", column)); //$NON-NLS-1$ xmlElement.addAttribute(new Attribute("sqlStatement", configuredSqlStatement)); //$NON-NLS-1$ - xmlElement.addAttribute(new Attribute("type", type)); - xmlElement.addAttribute(new Attribute("identity",//$NON-NLS-1$ + xmlElement.addAttribute(new Attribute("type", type)); //$NON-NLS-1$ + xmlElement.addAttribute(new Attribute("identity", //$NON-NLS-1$ isIdentity ? "true" : "false")); //$NON-NLS-1$ //$NON-NLS-2$ return xmlElement; Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/PropertyRegistry.java URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/PropertyRegistry.java?rev=618753&r1=618752&r2=618753&view=diff ============================================================================== --- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/PropertyRegistry.java (original) +++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/PropertyRegistry.java Tue Feb 5 11:24:41 2008 @@ -28,6 +28,16 @@ public class PropertyRegistry { public static final String ANY_ENABLE_SUB_PACKAGES = "enableSubPackages"; //$NON-NLS-1$ + /** + * recognized by table and java model generator + */ + public static final String ANY_ROOT_CLASS = "rootClass"; //$NON-NLS-1$ + + /** + * recognized by table and dao generator + */ + public static final String ANY_ROOT_INTERFACE = "rootInterface"; //$NON-NLS-1$ + public static final String TABLE_USE_COLUMN_INDEXES = "useColumnIndexes"; //$NON-NLS-1$ public static final String TABLE_USE_ACTUAL_COLUMN_NAMES = "useActualColumnNames"; //$NON-NLS-1$ public static final String TABLE_IGNORE_QUALIFIERS_AT_RUNTIME = "ignoreQualifiersAtRuntime"; //$NON-NLS-1$ @@ -39,10 +49,8 @@ public static final String DAO_EXAMPLE_METHOD_VISIBILITY = "exampleMethodVisibility"; //$NON-NLS-1$ public static final String DAO_METHOD_NAME_CALCULATOR = "methodNameCalculator"; //$NON-NLS-1$ - public static final String DAO_ROOT_INTERFACE = "rootInterface"; //$NON-NLS-1$ public static final String TYPE_RESOLVER_FORCE_BIG_DECIMALS = "forceBigDecimals"; //$NON-NLS-1$ - public static final String MODEL_GENERATOR_ROOT_CLASS = "rootClass"; //$NON-NLS-1$ public static final String MODEL_GENERATOR_TRIM_STRINGS = "trimStrings"; //$NON-NLS-1$ } 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=618753&r1=618752&r2=618753&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 Tue Feb 5 11:24:41 2008 @@ -481,6 +481,15 @@ errors .add(Messages.getString("ValidationError.7", //$NON-NLS-1$ fqTableName)); + + String type = generatedKey.getType(); + if (StringUtility.stringHasValue(type)) { + if (!"pre".equals(type) && !"post".equals(type)) { //$NON-NLS-1$ //$NON-NLS-2$ + errors + .add(Messages.getString("ValidationError.15", //$NON-NLS-1$ + fqTableName)); + } + } } if ("true".equalsIgnoreCase(getProperty(PropertyRegistry.TABLE_USE_COLUMN_INDEXES))) { //$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=618753&r1=618752&r2=618753&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 Tue Feb 5 11:24:41 2008 @@ -75,7 +75,7 @@ public AbatorConfigurationParser(Properties properties, List warnings) { super(); if (properties == null) { - this.properties = new Properties(); + this.properties = System.getProperties(); } else { this.properties = properties; } @@ -481,10 +481,6 @@ boolean identity = "true".equals(attributes.getProperty("identity")); //$NON-NLS-1$ //$NON-NLS-2$ String sqlStatement = attributes.getProperty("sqlStatement"); //$NON-NLS-1$ String type = attributes.getProperty("type"); //$NON-NLS-1$ - // if type is specified then set identity to false - if(type != null && !type.trim().equals("")) { - identity = false; - } GeneratedKey gk = new GeneratedKey(column, sqlStatement, identity, type); 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=618753&r1=618752&r2=618753&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 Tue Feb 5 11:24:41 2008 @@ -444,7 +444,11 @@ Interface answer = new Interface(getDAOInterfaceType(table)); answer.setVisibility(JavaVisibility.PUBLIC); - String rootInterface = properties.getProperty(PropertyRegistry.DAO_ROOT_INTERFACE); + String rootInterface = introspectedTable.getTableConfigurationProperty(PropertyRegistry.ANY_ROOT_INTERFACE); + if (rootInterface == null) { + rootInterface = properties.getProperty(PropertyRegistry.ANY_ROOT_INTERFACE); + } + if (StringUtility.stringHasValue(rootInterface)) { FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(rootInterface); answer.addSuperInterface(fqjt); 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=618753&r1=618752&r2=618753&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 Tue Feb 5 11:24:41 2008 @@ -240,7 +240,7 @@ TopLevelClass answer = new TopLevelClass(type); answer.setVisibility(JavaVisibility.PUBLIC); - String rootClass = properties.getProperty(PropertyRegistry.MODEL_GENERATOR_ROOT_CLASS); + String rootClass = getRootClass(introspectedTable); if (rootClass != null) { answer.setSuperClass(new FullyQualifiedJavaType(rootClass)); answer.addImportedType(answer.getSuperClass()); @@ -265,7 +265,7 @@ if (introspectedTable.getRules().generatePrimaryKeyClass()) { answer.setSuperClass(getPrimaryKeyType(table)); } else { - String rootClass = properties.getProperty(PropertyRegistry.MODEL_GENERATOR_ROOT_CLASS); + String rootClass = getRootClass(introspectedTable); if (rootClass != null) { answer.setSuperClass(new FullyQualifiedJavaType(rootClass)); answer.addImportedType(answer.getSuperClass()); @@ -1460,5 +1460,14 @@ public void setAbatorContext(AbatorContext abatorContext) { this.abatorContext = abatorContext; + } + + protected String getRootClass (IntrospectedTable introspectedTable) { + String rootClass = introspectedTable.getTableConfigurationProperty(PropertyRegistry.ANY_ROOT_CLASS); + if (rootClass == null) { + rootClass = properties.getProperty(PropertyRegistry.ANY_ROOT_CLASS); + } + + return rootClass; } } 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=618753&r1=618752&r2=618753&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 Tue Feb 5 11:24:41 2008 @@ -460,7 +460,7 @@ GeneratedKey gk = introspectedTable.getGeneratedKey(); - if (gk != null && !gk.isIdentity()) { + if (gk != null && gk.isBeforeInsert()) { ColumnDefinition cd = introspectedTable.getColumn(gk.getColumn()); // if the column is null, then it's a configuration error. The // warning has already been reported @@ -479,14 +479,12 @@ valuesClause.append("values ("); //$NON-NLS-1$ - ColumnDefinition identityColumn = null; boolean comma = false; Iterator iter = introspectedTable.getAllColumns(); while (iter.hasNext()) { ColumnDefinition cd = (ColumnDefinition) iter.next(); if (cd.isIdentity()) { - identityColumn = cd; // cannot set values on identity fields continue; } @@ -507,8 +505,14 @@ answer.addElement(new TextElement(insertClause.toString())); answer.addElement(new TextElement(valuesClause.toString())); - if (gk != null && identityColumn != null) { - answer.addElement(getSelectKey(identityColumn, gk)); + if (gk != null && !gk.isBeforeInsert()) { + ColumnDefinition cd = introspectedTable.getColumn(gk.getColumn()); + // if the column is null, then it's a configuration error. The + // warning has already been reported + if (cd != null) { + // pre-generated key + answer.addElement(getSelectKey(cd, gk)); + } } return answer; @@ -908,7 +912,7 @@ answer.addAttribute(new Attribute("resultClass", identityColumnType)); //$NON-NLS-1$ answer.addAttribute(new Attribute( "keyProperty", columnDefinition.getJavaProperty())); //$NON-NLS-1$ - if(generatedKey.getType() != null && !generatedKey.getType().trim().equals("")) { + if(StringUtility.stringHasValue(generatedKey.getType())) { answer.addAttribute(new Attribute("type", generatedKey.getType())); //$NON-NLS-1$ } answer.addElement(new TextElement(generatedKey.getRuntimeSqlStatement())); 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=618753&r1=618752&r2=618753&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 Tue Feb 5 11:24:41 2008 @@ -13,6 +13,7 @@ ValidationError.12={0} Target Package is Required for context {1} ValidationError.13=If "useColumnIndexes" property is set, then either both or neither query id must be set for table {0} ValidationError.14="searchString is required in a ColumnRenamingRule" +ValidationError.15=Generated key type must be either "pre" or "post" if the type is specified for a generated key for table {0} RuntimeError.0=configfile is a required parameter RuntimeError.1=configfile {0} does not exist