Ibator - generatedKey: attribute "type" is not checked when attribute
"sqlStatement" has a value
------------------------------------------------------------------------------------------------
Key: IBATIS-601
URL: https://issues.apache.org/jira/browse/IBATIS-601
Project: iBatis for Java
Issue Type: Bug
Components: Tools
Reporter: Karel Rank
With current SVN code, this configuration for table passes validation:
<table schema="adnot" tableName="sites" domainObjectName="Site">
<property name="useActualColumnNames" value="false"/>
<generatedKey column="site_id" sqlStatement="SELECT
nextval('adnot.sites_site_id_seq')" type="foobar"/>
<columnRenamingRule searchString="site_" replaceString=""/>
</table>
This configuration is not valid. Generated insert statements in SqlMap then
contains in "selectKey" attribute type="foobar". The problem is in
org.apache.ibatis.ibator.config.TableConfiguration, method validate. Here is
the fix.
Index: src/org/apache/ibatis/ibator/config/TableConfiguration.java
===================================================================
--- src/org/apache/ibatis/ibator/config/TableConfiguration.java (revision
774012)
+++ src/org/apache/ibatis/ibator/config/TableConfiguration.java (working copy)
@@ -474,12 +474,13 @@
String fqTableName = StringUtility.composeFullyQualifiedTableName(
catalog, schema, tableName, '.');
- if (generatedKey != null
- &&
!StringUtility.stringHasValue(generatedKey.getRuntimeSqlStatement())) {
- errors
- .add(Messages.getString("ValidationError.7", //$NON-NLS-1$
- fqTableName));
-
+ if (generatedKey != null) {
+ if
(!StringUtility.stringHasValue(generatedKey.getRuntimeSqlStatement())) {
+ 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$
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.