Author: cbegin
Date: Sun Dec 6 02:46:09 2009
New Revision: 887629
URL: http://svn.apache.org/viewvc?rev=887629&view=rev
Log:
ibatis-694 iBATIS wrongly blaims selectKey for null-values without jdbcType in
insert-statements
Modified:
ibatis/java/ibatis-3/trunk/ibatis-3-core/src/main/java/org/apache/ibatis/executor/ErrorContext.java
ibatis/java/ibatis-3/trunk/ibatis-3-core/src/main/java/org/apache/ibatis/executor/statement/CallableStatementHandler.java
ibatis/java/ibatis-3/trunk/ibatis-3-core/src/main/java/org/apache/ibatis/executor/statement/PreparedStatementHandler.java
Modified:
ibatis/java/ibatis-3/trunk/ibatis-3-core/src/main/java/org/apache/ibatis/executor/ErrorContext.java
URL:
http://svn.apache.org/viewvc/ibatis/java/ibatis-3/trunk/ibatis-3-core/src/main/java/org/apache/ibatis/executor/ErrorContext.java?rev=887629&r1=887628&r2=887629&view=diff
==============================================================================
---
ibatis/java/ibatis-3/trunk/ibatis-3-core/src/main/java/org/apache/ibatis/executor/ErrorContext.java
(original)
+++
ibatis/java/ibatis-3/trunk/ibatis-3-core/src/main/java/org/apache/ibatis/executor/ErrorContext.java
Sun Dec 6 02:46:09 2009
@@ -5,6 +5,7 @@
private static String NEWLINE; // Can't be final due to a weird Java
compiler issue.
private static final ThreadLocal<ErrorContext> LOCAL = new
ThreadLocal<ErrorContext>();
+ private ErrorContext stored;
private String resource;
private String activity;
private String object;
@@ -32,6 +33,20 @@
return context;
}
+ public ErrorContext store() {
+ stored = this;
+ LOCAL.set(new ErrorContext());
+ return LOCAL.get();
+ }
+
+ public ErrorContext recall() {
+ if (stored != null) {
+ LOCAL.set(stored);
+ stored = null;
+ }
+ return LOCAL.get();
+ }
+
public ErrorContext resource(String resource) {
this.resource = resource;
return this;
Modified:
ibatis/java/ibatis-3/trunk/ibatis-3-core/src/main/java/org/apache/ibatis/executor/statement/CallableStatementHandler.java
URL:
http://svn.apache.org/viewvc/ibatis/java/ibatis-3/trunk/ibatis-3-core/src/main/java/org/apache/ibatis/executor/statement/CallableStatementHandler.java?rev=887629&r1=887628&r2=887629&view=diff
==============================================================================
---
ibatis/java/ibatis-3/trunk/ibatis-3-core/src/main/java/org/apache/ibatis/executor/statement/CallableStatementHandler.java
(original)
+++
ibatis/java/ibatis-3/trunk/ibatis-3-core/src/main/java/org/apache/ibatis/executor/statement/CallableStatementHandler.java
Sun Dec 6 02:46:09 2009
@@ -1,7 +1,6 @@
package org.apache.ibatis.executor.statement;
-import org.apache.ibatis.executor.Executor;
-import org.apache.ibatis.executor.ExecutorException;
+import org.apache.ibatis.executor.*;
import org.apache.ibatis.executor.keygen.KeyGenerator;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.ParameterMapping;
@@ -56,7 +55,9 @@
public void parameterize(Statement statement) throws SQLException {
KeyGenerator keyGenerator = mappedStatement.getKeyGenerator();
+ ErrorContext.instance().store();
keyGenerator.processBefore(executor, mappedStatement, statement,
boundSql.getParameterObject());
+ ErrorContext.instance().recall();
rebindGeneratedKey();
registerOutputParameters((CallableStatement) statement);
parameterHandler.setParameters((CallableStatement) statement);
Modified:
ibatis/java/ibatis-3/trunk/ibatis-3-core/src/main/java/org/apache/ibatis/executor/statement/PreparedStatementHandler.java
URL:
http://svn.apache.org/viewvc/ibatis/java/ibatis-3/trunk/ibatis-3-core/src/main/java/org/apache/ibatis/executor/statement/PreparedStatementHandler.java?rev=887629&r1=887628&r2=887629&view=diff
==============================================================================
---
ibatis/java/ibatis-3/trunk/ibatis-3-core/src/main/java/org/apache/ibatis/executor/statement/PreparedStatementHandler.java
(original)
+++
ibatis/java/ibatis-3/trunk/ibatis-3-core/src/main/java/org/apache/ibatis/executor/statement/PreparedStatementHandler.java
Sun Dec 6 02:46:09 2009
@@ -1,6 +1,6 @@
package org.apache.ibatis.executor.statement;
-import org.apache.ibatis.executor.Executor;
+import org.apache.ibatis.executor.*;
import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator;
import org.apache.ibatis.executor.keygen.KeyGenerator;
import org.apache.ibatis.mapping.MappedStatement;
@@ -54,7 +54,9 @@
public void parameterize(Statement statement)
throws SQLException {
KeyGenerator keyGenerator = mappedStatement.getKeyGenerator();
+ ErrorContext.instance().store();
keyGenerator.processBefore(executor, mappedStatement, statement,
boundSql.getParameterObject());
+ ErrorContext.instance().recall();
rebindGeneratedKey();
parameterHandler.setParameters((PreparedStatement) statement);
}