Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
bc283ed7
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
bc283ed7
编写于
2月 28, 2019
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polishing
上级
f31f6540
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
45 addition
and
44 deletion
+45
-44
spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcOperations.java
...in/java/org/springframework/jdbc/core/JdbcOperations.java
+37
-36
spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java
...main/java/org/springframework/jdbc/core/JdbcTemplate.java
+8
-8
未找到文件。
spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcOperations.java
浏览文件 @
bc283ed7
...
...
@@ -166,14 +166,14 @@ public interface JdbcOperations {
<
T
>
T
queryForObject
(
String
sql
,
Class
<
T
>
requiredType
)
throws
DataAccessException
;
/**
* Execute a query for a result
M
ap, given static SQL.
* Execute a query for a result
m
ap, given static SQL.
* <p>Uses a JDBC Statement, not a PreparedStatement. If you want to
* execute a static query with a PreparedStatement, use the overloaded
* {@link #queryForMap(String, Object...)} method with {@code null}
* as argument array.
* <p>The query is expected to be a single row query; the result row will be
* mapped to a Map (one entry for each column, using the column name as the key).
* @param sql SQL query to execute
* @param sql
the
SQL query to execute
* @return the result Map (one entry per column, with column name as key)
* @throws IncorrectResultSizeDataAccessException if the query does not
* return exactly one row
...
...
@@ -208,7 +208,7 @@ public interface JdbcOperations {
* <p>The results will be mapped to a List (one entry for each row) of
* Maps (one entry for each column using the column name as the key).
* Each element in the list will be of the form returned by this interface's
*
queryForMap()
methods.
*
{@code queryForMap}
methods.
* @param sql the SQL query to execute
* @return an List that contains a Map per row
* @throws DataAccessException if there is any problem executing the query
...
...
@@ -558,8 +558,8 @@ public interface JdbcOperations {
<
T
>
T
queryForObject
(
String
sql
,
RowMapper
<
T
>
rowMapper
,
Object
...
args
)
throws
DataAccessException
;
/**
* Query given SQL to create a prepared statement from SQL and a
*
list of
arguments to bind to the query, expecting a result object.
* Query given SQL to create a prepared statement from SQL and a
list of
* arguments to bind to the query, expecting a result object.
* <p>The query is expected to be a single row/single column query; the returned
* result will be directly mapped to the corresponding object type.
* @param sql the SQL query to execute
...
...
@@ -578,8 +578,8 @@ public interface JdbcOperations {
throws
DataAccessException
;
/**
* Query given SQL to create a prepared statement from SQL and a
*
list of
arguments to bind to the query, expecting a result object.
* Query given SQL to create a prepared statement from SQL and a
list of
* arguments to bind to the query, expecting a result object.
* <p>The query is expected to be a single row/single column query; the returned
* result will be directly mapped to the corresponding object type.
* @param sql the SQL query to execute
...
...
@@ -597,8 +597,8 @@ public interface JdbcOperations {
<
T
>
T
queryForObject
(
String
sql
,
Object
[]
args
,
Class
<
T
>
requiredType
)
throws
DataAccessException
;
/**
* Query given SQL to create a prepared statement from SQL and a
*
list of
arguments to bind to the query, expecting a result object.
* Query given SQL to create a prepared statement from SQL and a
list of
* arguments to bind to the query, expecting a result object.
* <p>The query is expected to be a single row/single column query; the returned
* result will be directly mapped to the corresponding object type.
* @param sql the SQL query to execute
...
...
@@ -617,8 +617,8 @@ public interface JdbcOperations {
<
T
>
T
queryForObject
(
String
sql
,
Class
<
T
>
requiredType
,
Object
...
args
)
throws
DataAccessException
;
/**
* Query given SQL to create a prepared statement from SQL and a
*
list of arguments to bind to the query, expecting a result M
ap.
* Query given SQL to create a prepared statement from SQL and a
list of
*
arguments to bind to the query, expecting a result m
ap.
* <p>The query is expected to be a single row query; the result row will be
* mapped to a Map (one entry for each column, using the column name as the key).
* @param sql the SQL query to execute
...
...
@@ -636,11 +636,11 @@ public interface JdbcOperations {
Map
<
String
,
Object
>
queryForMap
(
String
sql
,
Object
[]
args
,
int
[]
argTypes
)
throws
DataAccessException
;
/**
* Query given SQL to create a prepared statement from SQL and a
*
list of arguments to bind to the query, expecting a result M
ap.
*
The queryForMap()
methods defined by this interface are appropriate
* when you don't have a domain model. Otherwise, consider using
*
one of the queryForObject()
methods.
* Query given SQL to create a prepared statement from SQL and a
list of
*
arguments to bind to the query, expecting a result m
ap.
*
<p>The {@code queryForMap}
methods defined by this interface are appropriate
* when you don't have a domain model. Otherwise, consider using
one of the
*
{@code queryForObject}
methods.
* <p>The query is expected to be a single row query; the result row will be
* mapped to a Map (one entry for each column, using the column name as the key).
* @param sql the SQL query to execute
...
...
@@ -659,8 +659,8 @@ public interface JdbcOperations {
Map
<
String
,
Object
>
queryForMap
(
String
sql
,
Object
...
args
)
throws
DataAccessException
;
/**
* Query given SQL to create a prepared statement from SQL and a
*
list of
arguments to bind to the query, expecting a result list.
* Query given SQL to create a prepared statement from SQL and a
list of
* arguments to bind to the query, expecting a result list.
* <p>The results will be mapped to a List (one entry for each row) of
* result objects, each of them matching the specified element type.
* @param sql the SQL query to execute
...
...
@@ -674,12 +674,12 @@ public interface JdbcOperations {
* @see #queryForList(String, Class)
* @see SingleColumnRowMapper
*/
<
T
>
List
<
T
>
queryForList
(
String
sql
,
Object
[]
args
,
int
[]
argTypes
,
Class
<
T
>
elementType
)
<
T
>
List
<
T
>
queryForList
(
String
sql
,
Object
[]
args
,
int
[]
argTypes
,
Class
<
T
>
elementType
)
throws
DataAccessException
;
/**
* Query given SQL to create a prepared statement from SQL and a
*
list of
arguments to bind to the query, expecting a result list.
* Query given SQL to create a prepared statement from SQL and a
list of
* arguments to bind to the query, expecting a result list.
* <p>The results will be mapped to a List (one entry for each row) of
* result objects, each of them matching the specified element type.
* @param sql the SQL query to execute
...
...
@@ -697,8 +697,8 @@ public interface JdbcOperations {
<
T
>
List
<
T
>
queryForList
(
String
sql
,
Object
[]
args
,
Class
<
T
>
elementType
)
throws
DataAccessException
;
/**
* Query given SQL to create a prepared statement from SQL and a
*
list of
arguments to bind to the query, expecting a result list.
* Query given SQL to create a prepared statement from SQL and a
list of
* arguments to bind to the query, expecting a result list.
* <p>The results will be mapped to a List (one entry for each row) of
* result objects, each of them matching the specified element type.
* @param sql the SQL query to execute
...
...
@@ -717,12 +717,12 @@ public interface JdbcOperations {
<
T
>
List
<
T
>
queryForList
(
String
sql
,
Class
<
T
>
elementType
,
Object
...
args
)
throws
DataAccessException
;
/**
* Query given SQL to create a prepared statement from SQL and a
*
list of
arguments to bind to the query, expecting a result list.
* Query given SQL to create a prepared statement from SQL and a
list of
* arguments to bind to the query, expecting a result list.
* <p>The results will be mapped to a List (one entry for each row) of
* Maps (one entry for each column, using the column name as the key).
*
Thus
Each element in the list will be of the form returned by this interface's
*
queryForMap()
methods.
* Each element in the list will be of the form returned by this interface's
*
{@code queryForMap}
methods.
* @param sql the SQL query to execute
* @param args arguments to bind to the query
* @param argTypes the SQL types of the arguments
...
...
@@ -735,12 +735,12 @@ public interface JdbcOperations {
List
<
Map
<
String
,
Object
>>
queryForList
(
String
sql
,
Object
[]
args
,
int
[]
argTypes
)
throws
DataAccessException
;
/**
* Query given SQL to create a prepared statement from SQL and a
*
list of
arguments to bind to the query, expecting a result list.
* Query given SQL to create a prepared statement from SQL and a
list of
* arguments to bind to the query, expecting a result list.
* <p>The results will be mapped to a List (one entry for each row) of
* Maps (one entry for each column, using the column name as the key).
* Each element in the list will be of the form returned by this interface's
*
queryForMap()
methods.
*
{@code queryForMap}
methods.
* @param sql the SQL query to execute
* @param args arguments to bind to the query
* (leaving it to the PreparedStatement to guess the corresponding SQL type);
...
...
@@ -753,8 +753,8 @@ public interface JdbcOperations {
List
<
Map
<
String
,
Object
>>
queryForList
(
String
sql
,
Object
...
args
)
throws
DataAccessException
;
/**
* Query given SQL to create a prepared statement from SQL and a
*
list of
arguments to bind to the query, expecting a SqlRowSet.
* Query given SQL to create a prepared statement from SQL and a
list of
* arguments to bind to the query, expecting a SqlRowSet.
* <p>The results will be mapped to an SqlRowSet which holds the data in a
* disconnected fashion. This wrapper will translate any SQLExceptions thrown.
* <p>Note that, for the default implementation, JDBC RowSet support needs to
...
...
@@ -776,8 +776,8 @@ public interface JdbcOperations {
SqlRowSet
queryForRowSet
(
String
sql
,
Object
[]
args
,
int
[]
argTypes
)
throws
DataAccessException
;
/**
* Query given SQL to create a prepared statement from SQL and a
*
list of
arguments to bind to the query, expecting a SqlRowSet.
* Query given SQL to create a prepared statement from SQL and a
list of
* arguments to bind to the query, expecting a SqlRowSet.
* <p>The results will be mapped to an SqlRowSet which holds the data in a
* disconnected fashion. This wrapper will translate any SQLExceptions thrown.
* <p>Note that, for the default implementation, JDBC RowSet support needs to
...
...
@@ -799,8 +799,9 @@ public interface JdbcOperations {
SqlRowSet
queryForRowSet
(
String
sql
,
Object
...
args
)
throws
DataAccessException
;
/**
* Issue a single SQL update operation (such as an insert, update or delete statement)
* using a PreparedStatementCreator to provide SQL and any required parameters.
* Issue a single SQL update operation (such as an insert, update or delete
* statement) using a PreparedStatementCreator to provide SQL and any
* required parameters.
* <p>A PreparedStatementCreator can either be implemented directly or
* configured through a PreparedStatementCreatorFactory.
* @param psc a callback that provides SQL and any necessary parameters
...
...
spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java
浏览文件 @
bc283ed7
...
...
@@ -1145,12 +1145,12 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
logger
.
debug
(
"CallableStatement.execute() returned '"
+
retVal
+
"'"
);
logger
.
debug
(
"CallableStatement.getUpdateCount() returned "
+
updateCount
);
}
Map
<
String
,
Object
>
re
turnedResults
=
createResultsMap
();
Map
<
String
,
Object
>
re
sultsMap
=
createResultsMap
();
if
(
retVal
||
updateCount
!=
-
1
)
{
re
turnedResults
.
putAll
(
extractReturnedResults
(
cs
,
updateCountParameters
,
resultSetParameters
,
updateCount
));
re
sultsMap
.
putAll
(
extractReturnedResults
(
cs
,
updateCountParameters
,
resultSetParameters
,
updateCount
));
}
re
turnedResults
.
putAll
(
extractOutputParameters
(
cs
,
callParameters
));
return
re
turnedResults
;
re
sultsMap
.
putAll
(
extractOutputParameters
(
cs
,
callParameters
));
return
re
sultsMap
;
}
});
}
...
...
@@ -1283,8 +1283,8 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
}
if
(
param
.
getRowMapper
()
!=
null
)
{
RowMapper
rowMapper
=
param
.
getRowMapper
();
Object
result
=
(
new
RowMapperResultSetExtractor
(
rowMapper
)).
extractData
(
rsToUse
);
return
Collections
.
singletonMap
(
param
.
getName
(),
result
);
Object
data
=
(
new
RowMapperResultSetExtractor
(
rowMapper
)).
extractData
(
rsToUse
);
return
Collections
.
singletonMap
(
param
.
getName
(),
data
);
}
else
if
(
param
.
getRowCallbackHandler
()
!=
null
)
{
RowCallbackHandler
rch
=
param
.
getRowCallbackHandler
();
...
...
@@ -1293,8 +1293,8 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
(
Object
)
"ResultSet returned from stored procedure was processed"
);
}
else
if
(
param
.
getResultSetExtractor
()
!=
null
)
{
Object
result
=
param
.
getResultSetExtractor
().
extractData
(
rsToUse
);
return
Collections
.
singletonMap
(
param
.
getName
(),
result
);
Object
data
=
param
.
getResultSetExtractor
().
extractData
(
rsToUse
);
return
Collections
.
singletonMap
(
param
.
getName
(),
data
);
}
}
finally
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录