Skip to content

Commit

Permalink
fixed #209 Limit concurrent error
Browse files Browse the repository at this point in the history
  • Loading branch information
gaohongtao committed Dec 15, 2016
1 parent 0b8fd82 commit 8c77d99
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,11 @@ public SQLRouteResult route(final List<Object> parameters) {
tableRuleOptional = shardingRule.tryFindTableRule(sqlParsedResult.getRouteContext().getTables().iterator().next().getName());
} else {
generateId(parameters);
engine.setParameters(parameters);
for (ConditionContext each : sqlParsedResult.getConditionContexts()) {
each.setNewConditionValue(parameters);
}
}
return engine.routeSQL(sqlParsedResult);
return engine.routeSQL(sqlParsedResult, parameters);
}

private void generateId(final List<Object> parameters) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import com.google.common.collect.Collections2;
import com.google.common.collect.Sets;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

import java.util.Collections;
Expand All @@ -55,9 +54,6 @@ public final class SQLRouteEngine {

private final DatabaseType databaseType;

@Setter
private List<Object> parameters;

/**
* SQL路由.
*
Expand All @@ -70,7 +66,7 @@ public SQLRouteResult route(final String logicSql) throws SQLParserException {
}

SQLRouteResult route(final String logicSql, final List<Object> parameters) throws SQLParserException {
return routeSQL(parseSQL(logicSql, parameters));
return routeSQL(parseSQL(logicSql, parameters), parameters);
}

/**
Expand All @@ -84,14 +80,13 @@ public PreparedSQLRouter prepareSQL(final String logicSql) {
}

SQLParsedResult parseSQL(final String logicSql, final List<Object> parameters) {
this.parameters = parameters;
Context context = MetricsContext.start("Parse SQL");
SQLParsedResult result = SQLParserFactory.create(databaseType, logicSql, parameters, shardingRule).parse();
MetricsContext.stop(context);
return result;
}

SQLRouteResult routeSQL(final SQLParsedResult parsedResult) {
SQLRouteResult routeSQL(final SQLParsedResult parsedResult, final List<Object> parameters) {
Context context = MetricsContext.start("Route SQL");
SQLRouteResult result = new SQLRouteResult(parsedResult.getRouteContext().getSqlStatementType(), parsedResult.getMergeContext(), parsedResult.getGeneratedKeyContext());
for (ConditionContext each : parsedResult.getConditionContexts()) {
Expand Down
3 changes: 2 additions & 1 deletion sharding-jdbc-doc/content/post/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ weight = 1
1. [ISSUE #194](https://github.com/dangdangdotcom/sharding-jdbc/issues/194) jdbc接口中资源释放错误
1. [ISSUE #199](https://github.com/dangdangdotcom/sharding-jdbc/issues/199) 分表且复用PreparedStatement对象造成数据路由错误
1. [ISSUE #201](https://github.com/dangdangdotcom/sharding-jdbc/issues/201) 批量操作执行前事件发送缺失
1. [ISSUE #203](https://github.com/dangdangdotcom/sharding-jdbc/issues/201) 合并batch操作发送的事件
1. [ISSUE #203](https://github.com/dangdangdotcom/sharding-jdbc/issues/203) 合并batch操作发送的事件
1. [ISSUE #209](https://github.com/dangdangdotcom/sharding-jdbc/issues/209) limit并行异常

## 1.4.0

Expand Down

0 comments on commit 8c77d99

Please sign in to comment.