use of com.dangdang.ddframe.rdb.sharding.executor.StatementExecutor in project sharding-jdbc by dangdangdotcom.
the class ShardingStatement method generateExecutor.
private StatementExecutor generateExecutor(final String sql) throws SQLException {
StatementExecutor result = new StatementExecutor(shardingConnection.getShardingContext().getExecutorEngine());
SQLRouteResult sqlRouteResult = shardingConnection.getShardingContext().getSqlRouteEngine().route(sql);
generatedKeyContext = sqlRouteResult.getGeneratedKeyContext();
mergeContext = sqlRouteResult.getMergeContext();
for (SQLExecutionUnit each : sqlRouteResult.getExecutionUnits()) {
Statement statement = getStatement(shardingConnection.getConnection(each.getDataSource(), sqlRouteResult.getSqlStatementType()), each.getSql());
replayMethodsInvocation(statement);
result.addStatement(new StatementExecutorWrapper(statement, each));
}
return result;
}
Aggregations