Commit 40cae730 authored by Quxl's avatar Quxl

x

parent 9c04b9f4
......@@ -487,19 +487,14 @@ public class JdbcTemplate extends org.springframework.jdbc.core.JdbcTemplate {
public ResultMutil executeMutil(final String sql, final Object... args) {
showSql(sql, args);
Map<Integer, OutParameter> out = new HashMap<Integer, OutParameter>();
return super.execute(new CallableStatementCreator() {
public CallableStatement createCallableStatement(final Connection con) throws SQLException {
final CallableStatement cs = con.prepareCall(sql);
for(int i = 0; i < args.length; i++) {
Integer index = i + 1;
Object arg = args[i];
if(arg != null && arg instanceof OutParameter) {
out.put(index, (OutParameter)arg);
} else {
cs.setObject(index, arg);
}
}
return cs;
}
}, new CallableStatementCallback<ResultMutil>() {
......@@ -521,11 +516,6 @@ public class JdbcTemplate extends org.springframework.jdbc.core.JdbcTemplate {
cs.getMoreResults();
}
}
if(out.size() > 0) {
for(Integer key : out.keySet()) {
out.get(key).setValue(cs.getObject(key));
}
}
return new ResultMutil(datas, counts);
}
});
......@@ -533,11 +523,18 @@ public class JdbcTemplate extends org.springframework.jdbc.core.JdbcTemplate {
public List<Object> exec(final String sql, final Object... args) {
showSql(sql, args);
Map<Integer, OutParameter> out = new HashMap<Integer, OutParameter>();
return super.execute(new CallableStatementCreator() {
public CallableStatement createCallableStatement(final Connection con) throws SQLException {
final CallableStatement cs = con.prepareCall(sql);
for(int i = 0; i < args.length; i++) {
cs.setObject(i+1, args[i]);
Integer index = i + 1;
Object arg = args[i];
if(arg != null && arg instanceof OutParameter) {
out.put(index, (OutParameter)arg);
} else {
cs.setObject(index, arg);
}
}
return cs;
}
......@@ -559,6 +556,11 @@ public class JdbcTemplate extends org.springframework.jdbc.core.JdbcTemplate {
cs.getMoreResults();
}
}
if(out.size() > 0) {
for(Integer key : out.keySet()) {
out.get(key).setValue(cs.getObject(key));
}
}
return datas;
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment