Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
48c74f22
Shardingsphere
项目概览
apache
/
Shardingsphere
通知
56
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Shardingsphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
48c74f22
编写于
9月 12, 2017
作者:
T
terrymanu
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/1.5.4-SNAPSHOT' into 2.0.0.M1
上级
6dac7c0f
fdeac9bc
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
32 addition
and
34 deletion
+32
-34
RELEASE-NOTES.md
RELEASE-NOTES.md
+1
-0
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/jdbc/core/statement/ShardingPreparedStatement.java
...arding/jdbc/core/statement/ShardingPreparedStatement.java
+31
-34
未找到文件。
RELEASE-NOTES.md
浏览文件 @
48c74f22
...
...
@@ -4,6 +4,7 @@
1.
[
ISSUE #356
](
https://github.com/dangdangdotcom/sharding-jdbc/issues/356
)
在SQL的Where条件中兼容不是分片列的REGEXP操作符
1.
[
ISSUE #362
](
https://github.com/dangdangdotcom/sharding-jdbc/issues/362
)
读写分离使用PreparedStatement并未调用setParameter方法导致出错
1.
[
ISSUE #370
](
https://github.com/dangdangdotcom/sharding-jdbc/issues/370
)
使用原生自增主键调用getGeneratedKeys出错
## 1.5.3
...
...
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/jdbc/core/statement/ShardingPreparedStatement.java
浏览文件 @
48c74f22
...
...
@@ -174,19 +174,9 @@ public final class ShardingPreparedStatement extends AbstractShardingPreparedSta
}
private
PreparedStatement
generatePreparedStatement
(
final
SQLExecutionUnit
sqlExecutionUnit
)
throws
SQLException
{
Optional
<
GeneratedKey
>
generatedKey
=
getGeneratedKey
();
Connection
connection
=
getConnection
().
getConnection
(
sqlExecutionUnit
.
getDataSource
(),
routeResult
.
getSqlStatement
().
getType
());
if
(
returnGeneratedKeys
&&
generatedKey
.
isPresent
())
{
return
connection
.
prepareStatement
(
sqlExecutionUnit
.
getSql
(),
RETURN_GENERATED_KEYS
);
}
return
connection
.
prepareStatement
(
sqlExecutionUnit
.
getSql
(),
resultSetType
,
resultSetConcurrency
,
resultSetHoldability
);
}
private
Optional
<
GeneratedKey
>
getGeneratedKey
()
{
if
(
null
!=
routeResult
&&
routeResult
.
getSqlStatement
()
instanceof
InsertStatement
)
{
return
Optional
.
fromNullable
(((
InsertStatement
)
routeResult
.
getSqlStatement
()).
getGeneratedKey
());
}
return
Optional
.
absent
();
return
returnGeneratedKeys
?
connection
.
prepareStatement
(
sqlExecutionUnit
.
getSql
(),
RETURN_GENERATED_KEYS
)
:
connection
.
prepareStatement
(
sqlExecutionUnit
.
getSql
(),
resultSetType
,
resultSetConcurrency
,
resultSetHoldability
);
}
@Override
...
...
@@ -211,28 +201,6 @@ public final class ShardingPreparedStatement extends AbstractShardingPreparedSta
}
}
@Override
public
int
[]
executeBatch
()
throws
SQLException
{
try
{
return
new
BatchPreparedStatementExecutor
(
getConnection
().
getShardingContext
().
getExecutorEngine
(),
getConnection
().
getShardingContext
().
getDatabaseType
(),
routeResult
.
getSqlStatement
().
getType
(),
batchStatementUnits
,
parameterSets
).
executeBatch
();
}
finally
{
clearBatch
();
}
}
@Override
public
ResultSet
getGeneratedKeys
()
throws
SQLException
{
Optional
<
GeneratedKey
>
generatedKey
=
getGeneratedKey
();
if
(
returnGeneratedKeys
&&
generatedKey
.
isPresent
())
{
return
new
GeneratedKeysResultSet
(
routeResult
.
getGeneratedKeys
().
iterator
(),
generatedKey
.
get
().
getColumn
(),
this
);
}
if
(
1
==
routedStatements
.
size
())
{
return
routedStatements
.
iterator
().
next
().
getGeneratedKeys
();
}
return
new
GeneratedKeysResultSet
();
}
private
List
<
BatchPreparedStatementUnit
>
routeBatch
()
throws
SQLException
{
List
<
BatchPreparedStatementUnit
>
result
=
new
ArrayList
<>();
routeResult
=
routingEngine
.
route
(
getParameters
());
...
...
@@ -260,6 +228,35 @@ public final class ShardingPreparedStatement extends AbstractShardingPreparedSta
return
result
;
}
@Override
public
int
[]
executeBatch
()
throws
SQLException
{
try
{
return
new
BatchPreparedStatementExecutor
(
getConnection
().
getShardingContext
().
getExecutorEngine
(),
getConnection
().
getShardingContext
().
getDatabaseType
(),
routeResult
.
getSqlStatement
().
getType
(),
batchStatementUnits
,
parameterSets
).
executeBatch
();
}
finally
{
clearBatch
();
}
}
@Override
public
ResultSet
getGeneratedKeys
()
throws
SQLException
{
Optional
<
GeneratedKey
>
generatedKey
=
getGeneratedKey
();
if
(
returnGeneratedKeys
&&
generatedKey
.
isPresent
())
{
return
new
GeneratedKeysResultSet
(
routeResult
.
getGeneratedKeys
().
iterator
(),
generatedKey
.
get
().
getColumn
(),
this
);
}
if
(
1
==
routedStatements
.
size
())
{
return
routedStatements
.
iterator
().
next
().
getGeneratedKeys
();
}
return
new
GeneratedKeysResultSet
();
}
private
Optional
<
GeneratedKey
>
getGeneratedKey
()
{
if
(
null
!=
routeResult
&&
routeResult
.
getSqlStatement
()
instanceof
InsertStatement
)
{
return
Optional
.
fromNullable
(((
InsertStatement
)
routeResult
.
getSqlStatement
()).
getGeneratedKey
());
}
return
Optional
.
absent
();
}
@Override
public
ResultSet
getResultSet
()
throws
SQLException
{
if
(
null
!=
currentResultSet
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录