Search in sources :

Example 1 with StatementExecutor

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;
}
Also used : SQLRouteResult(com.dangdang.ddframe.rdb.sharding.router.SQLRouteResult) Statement(java.sql.Statement) SQLExecutionUnit(com.dangdang.ddframe.rdb.sharding.router.SQLExecutionUnit) StatementExecutor(com.dangdang.ddframe.rdb.sharding.executor.StatementExecutor) StatementExecutorWrapper(com.dangdang.ddframe.rdb.sharding.executor.wrapper.StatementExecutorWrapper)

Aggregations

StatementExecutor (com.dangdang.ddframe.rdb.sharding.executor.StatementExecutor)1 StatementExecutorWrapper (com.dangdang.ddframe.rdb.sharding.executor.wrapper.StatementExecutorWrapper)1 SQLExecutionUnit (com.dangdang.ddframe.rdb.sharding.router.SQLExecutionUnit)1 SQLRouteResult (com.dangdang.ddframe.rdb.sharding.router.SQLRouteResult)1 Statement (java.sql.Statement)1