Author: cbegin
Date: Wed May 6 02:50:42 2009
New Revision: 772033
URL: http://svn.apache.org/viewvc?rev=772033&view=rev
Log:
added statementType to statement elements
Added:
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/parser/xml/XMLStatementParser.java
Modified:
ibatis/trunk/java/ibatis-3/TODO
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/parser/xml/XMLMapperParser.java
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/parser/xml/ibatis-3-mapper.dtd
Modified: ibatis/trunk/java/ibatis-3/TODO
URL:
http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/TODO?rev=772033&r1=772032&r2=772033&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/TODO (original)
+++ ibatis/trunk/java/ibatis-3/TODO Wed May 6 02:50:42 2009
@@ -5,10 +5,8 @@
* Add resultType automapping option for collections so a resultMap isn' t
required
* Auto result/param types detected for bound XML statements
* Named parameter parsing/merging
-* Statement and Procedure statement type attribute on SQL elements
-* Return selectKey or autogen key from session.insert()
* commitRequired option at the statement level
-
+* Return selectKey or autogen key from session.insert()
* Dynamic SQL XML Parser
<where>
Modified:
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/parser/xml/XMLMapperParser.java
URL:
http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/parser/xml/XMLMapperParser.java?rev=772033&r1=772032&r2=772033&view=diff
==============================================================================
---
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/parser/xml/XMLMapperParser.java
(original)
+++
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/parser/xml/XMLMapperParser.java
Wed May 6 02:50:42 2009
@@ -201,61 +201,32 @@
// <select ...>
@Nodelet("/mapper/select")
public void selectElement(NodeletContext context) throws Exception {
- buildStatementFromContext(context, StatementType.PREPARED);
+ buildStatementFromContext(context);
}
// <insert ...>
@Nodelet("/mapper/insert")
public void insertElement(NodeletContext context) throws Exception {
- buildStatementFromContext(context, StatementType.PREPARED);
+ buildStatementFromContext(context);
}
// <update ...>
@Nodelet("/mapper/update")
public void updateElement(NodeletContext context) throws Exception {
- buildStatementFromContext(context, StatementType.PREPARED);
+ buildStatementFromContext(context);
}
// <delete ...>
@Nodelet("/mapper/delete")
public void deleteElement(NodeletContext context) throws Exception {
- buildStatementFromContext(context, StatementType.PREPARED);
+ buildStatementFromContext(context);
}
- // <procedure ...>
- @Nodelet("/mapper/procedure")
- public void procedureElement(NodeletContext context) throws Exception {
- buildStatementFromContext(context, StatementType.CALLABLE);
- }
-
- // <procedure ...>
- @Nodelet("/mapper/statement")
- public void statementElement(NodeletContext context) throws Exception {
- buildStatementFromContext(context, StatementType.STATEMENT);
- }
-
- private void buildStatementFromContext(NodeletContext context, StatementType
statementType) {
- String id = context.getStringAttribute("id");
- String sql = context.getStringBody();
- Integer fetchSize = context.getIntAttribute("fetchSize", null);
- Integer timeout = context.getIntAttribute("timeout", null);
- boolean isSelect = "select".equals(context.getNode().getNodeName());
- boolean flushCache = context.getBooleanAttribute("flushCache", !isSelect);
- boolean useCache = context.getBooleanAttribute("useCache", isSelect);
- String parameterMap = context.getStringAttribute("parameterMap");
- String parameterType = context.getStringAttribute("parameterType");
- Class parameterTypeClass = resolveClass(parameterType);
- String resultMap = context.getStringAttribute("resultMap");
- String resultType = context.getStringAttribute("resultType");
- Class resultTypeClass = resolveClass(resultType);
- String resultSetType = context.getStringAttribute("resultSetType");
- ResultSetType resultSetTypeEnum = resolveResultSetType(resultSetType);
- SqlSource sqlSource = new SqlSourceParser(configuration).parse(sql);
- sequentialBuilder.statement(id, sqlSource, fetchSize, timeout,
parameterMap, parameterTypeClass,
- resultMap, resultTypeClass, resultSetTypeEnum, isSelect, flushCache,
useCache, statementType);
+ private void buildStatementFromContext(NodeletContext context) {
+ final XMLStatementParser statementParser = new
XMLStatementParser(configuration, sequentialBuilder);
+ statementParser.parseStatementNode(context);
}
-
private void buildResultMappingFromContext(NodeletContext context,
ArrayList<ResultFlag> flags) {
String property = context.getStringAttribute("property");
String column = context.getStringAttribute("column");
Added:
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/parser/xml/XMLStatementParser.java
URL:
http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/parser/xml/XMLStatementParser.java?rev=772033&view=auto
==============================================================================
---
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/parser/xml/XMLStatementParser.java
(added)
+++
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/parser/xml/XMLStatementParser.java
Wed May 6 02:50:42 2009
@@ -0,0 +1,40 @@
+package org.apache.ibatis.parser.xml;
+
+import org.apache.ibatis.xml.NodeletContext;
+import org.apache.ibatis.mapping.*;
+import org.apache.ibatis.parser.*;
+
+public class XMLStatementParser extends BaseParser {
+
+ protected SequentialMapperBuilder sequentialBuilder;
+
+ public XMLStatementParser(Configuration configuration,
SequentialMapperBuilder sequentialBuilder) {
+ super(configuration);
+ this.sequentialBuilder = sequentialBuilder;
+ }
+
+ public void parseStatementNode(NodeletContext context) {
+ String id = context.getStringAttribute("id");
+ String sql = context.getStringBody();
+ Integer fetchSize = context.getIntAttribute("fetchSize", null);
+ Integer timeout = context.getIntAttribute("timeout", null);
+ boolean isSelect = "select".equals(context.getNode().getNodeName());
+ boolean flushCache = context.getBooleanAttribute("flushCache", !isSelect);
+ boolean useCache = context.getBooleanAttribute("useCache", isSelect);
+ String parameterMap = context.getStringAttribute("parameterMap");
+ String parameterType = context.getStringAttribute("parameterType");
+ Class parameterTypeClass = resolveClass(parameterType);
+ String resultMap = context.getStringAttribute("resultMap");
+ String resultType = context.getStringAttribute("resultType");
+ Class resultTypeClass = resolveClass(resultType);
+ String resultSetType = context.getStringAttribute("resultSetType");
+ StatementType statementType =
StatementType.valueOf(context.getStringAttribute("statementType",
StatementType.PREPARED.toString()));
+ ResultSetType resultSetTypeEnum = resolveResultSetType(resultSetType);
+ SqlSource sqlSource = new SqlSourceParser(configuration).parse(sql);
+ sequentialBuilder.statement(id, sqlSource, fetchSize, timeout,
parameterMap, parameterTypeClass,
+ resultMap, resultTypeClass, resultSetTypeEnum, isSelect, flushCache,
useCache, statementType);
+ }
+
+
+
+}
Modified:
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/parser/xml/ibatis-3-mapper.dtd
URL:
http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/parser/xml/ibatis-3-mapper.dtd?rev=772033&r1=772032&r2=772033&view=diff
==============================================================================
---
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/parser/xml/ibatis-3-mapper.dtd
(original)
+++
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/parser/xml/ibatis-3-mapper.dtd
Wed May 6 02:50:42 2009
@@ -136,6 +136,7 @@
resultMap CDATA #IMPLIED
resultType CDATA #IMPLIED
resultSetType (FORWARD_ONLY | SCROLL_INSENSITIVE | SCROLL_SENSITIVE) #IMPLIED
+statementType (STATEMENT|PREPARED|CALLABLE) #IMPLIED
fetchSize CDATA #IMPLIED
timeout CDATA #IMPLIED
flushCache (true|false) #IMPLIED
@@ -149,11 +150,13 @@
parameterType CDATA #IMPLIED
timeout CDATA #IMPLIED
flushCache (true|false) #IMPLIED
+statementType (STATEMENT|PREPARED|CALLABLE) #IMPLIED
>
<!ELEMENT selectKey (#PCDATA | include | prefix | where | set | foreach |
choose | if)*>
<!ATTLIST selectKey
resultType CDATA #IMPLIED
+statementType (STATEMENT|PREPARED|CALLABLE) #IMPLIED
keyProperty CDATA #IMPLIED
order (before|after) #IMPLIED
>
@@ -165,6 +168,7 @@
parameterType CDATA #IMPLIED
timeout CDATA #IMPLIED
flushCache (true|false) #IMPLIED
+statementType (STATEMENT|PREPARED|CALLABLE) #IMPLIED
>
<!ELEMENT delete (#PCDATA | include | prefix | where | set | foreach | choose
| if)*>
@@ -174,6 +178,7 @@
parameterType CDATA #IMPLIED
timeout CDATA #IMPLIED
flushCache (true|false) #IMPLIED
+statementType (STATEMENT|PREPARED|CALLABLE) #IMPLIED
>
<!-- Dynamic -->