Author: bgoodin
Date: Sat Oct 20 00:52:33 2007
New Revision: 586677

URL: http://svn.apache.org/viewvc?rev=586677&view=rev
Log:
- added ability to provide a type attribute on selectKey using <generatedKey 
... type="post"/>
- changed placeholder functionalithy to leave placeholder literals when they do 
not resolve to a property so ${myProperty} does not get changed to myProperty 
when it doesn't resolve. It is added to the sqlmap as ${myProperty}. This 
allows you to pass through properties that can be resolved with iBATIS.
- added behavior that if type is specified identity is automatically false on 
generatedKey
- updated dtd and made generatedKey identity #IMPLIED and type #IMPLIED

M    abator/core/build/version.properties
M    abator/core/src/org/apache/ibatis/abator/config/GeneratedKey.java
M    abator/core/src/org/apache/ibatis/abator/config/xml/abator-config_1_0.dtd
M    
abator/core/src/org/apache/ibatis/abator/config/xml/AbatorConfigurationParser.java
M    
abator/core/src/org/apache/ibatis/abator/internal/sqlmap/SqlMapGeneratorIterateImpl.java

Modified:
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/build/version.properties
    
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/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/sqlmap/SqlMapGeneratorIterateImpl.java

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=586677&r1=586676&r2=586677&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 
Sat Oct 20 00:52:33 2007
@@ -1,4 +1,4 @@
-#Abator build version info
-#Mon Sep 24 17:03:48 CDT 2007
-version=1.1.0
-buildNum=392
+#Abator build version info
+#Sat Oct 20 02:24:15 CDT 2007
+version=1.1.0
+buildNum=399

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=586677&r1=586676&r2=586677&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
 Sat Oct 20 00:52:33 2007
@@ -34,12 +34,15 @@
     
     private boolean isIdentity;
 
+    private String type;
+
     /**
      * 
      */
-    public GeneratedKey(String column, String configuredSqlStatement, boolean 
isIdentity) {
+    public GeneratedKey(String column, String configuredSqlStatement, boolean 
isIdentity, String type) {
         super();
         this.column = column;
+        this.type = type;
         this.isIdentity = isIdentity;
         this.configuredSqlStatement = configuredSqlStatement;
         
@@ -62,11 +65,16 @@
     public String getRuntimeSqlStatement() {
         return runtimeSqlStatement;
     }
+
+    public String getType() {
+        return type;
+    }
     
     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$
                 isIdentity ? "true" : "false")); //$NON-NLS-1$ //$NON-NLS-2$
         

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=586677&r1=586676&r2=586677&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
 Sat Oct 20 00:52:33 2007
@@ -477,8 +477,13 @@
         String column = attributes.getProperty("column"); //$NON-NLS-1$
         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);
+        GeneratedKey gk = new GeneratedKey(column, sqlStatement, identity, 
type);
 
         tc.setGeneratedKey(gk);
     }
@@ -667,14 +672,12 @@
                 String propName = newString.substring(start + OPEN.length(),
                         end);
                 String propValue = properties.getProperty(propName);
-                if (propValue == null) {
-                    newString = prepend + propName + append;
-                } else {
+                if (propValue != null) {
                     newString = prepend + propValue + append;
                 }
 
-                start = newString.indexOf(OPEN);
-                end = newString.indexOf(CLOSE);
+                start = newString.indexOf(OPEN,end);
+                end = newString.indexOf(CLOSE,end);
             }
         }
 

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=586677&r1=586676&r2=586677&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
 Sat Oct 20 00:52:33 2007
@@ -185,5 +185,6 @@
 <!ATTLIST generatedKey
   column CDATA #REQUIRED
   sqlStatement CDATA #REQUIRED
-  identity CDATA #REQUIRED>
+  identity CDATA #IMPLIED
+  type CDATA #IMPLIED>
   

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=586677&r1=586676&r2=586677&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
 Sat Oct 20 00:52:33 2007
@@ -908,6 +908,9 @@
         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("")) {
+          answer.addAttribute(new Attribute("type", generatedKey.getType())); 
//$NON-NLS-1$  
+        }
         answer.addElement(new 
TextElement(generatedKey.getRuntimeSqlStatement()));
 
         return answer;


Reply via email to