selectKey execution order attribute
-----------------------------------

         Key: IBATIS-277
         URL: http://issues.apache.org/jira/browse/IBATIS-277
     Project: iBatis for Java
        Type: Improvement
  Components: SQL Maps  
    Versions: 2.1.7    
 Environment: Any
    Reporter: Jamison


I did some poking around and found that iBatis for .NET has a 'type' attribute 
for the selectKey element that controls when the selectKey is executed. It 
would be beneficial to me if this attribute was introduced (possible values pre 
or post) because it would reduce changing the order of execution changing a 
property in an included property file instead of a rather painful process that 
requires a lot of manual intervention.

The following code would do it I think, but I have not actually tested it since 
I don't have an iBatis dev env set up.. please forgive my laziness. 
Line 301 of com.ibatis.sqlmap.engine.builder.xml.SqlStatementParser:
if (selectKeyStatement != null) {
  Properties attributes = NodeletUtils.parseAttributes(node, vars.properties);

  String keyType = attributes.getProperty("type", foundTextFirst ? "post" : 
"pre");
  //  I think I should throw an exception if it is not pre or post...
  if (!(keyType.equlas("pre") || keyType.equlas("post"))){
    throw new SqlMapException("Error.  selectKey type attribute value invalid: 
" + keyType);
  }

  selectKeyStatement.setAfter(keyPropName.equals("post"));

}

Of course the DTD would need to be changed too:
<!ELEMENT selectKey (#PCDATA | include)*>

<!ATTLIST selectKey

resultClass CDATA #IMPLIED

keyProperty CDATA #IMPLIED
type CDATA #IMPLIED

>

It is a truly minute code change and it would save my team an incredible amount 
of very error-prone work.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to