Search in sources :

Example 1 with DatabaseHintRoutingEngine

use of io.shardingjdbc.core.routing.type.hint.DatabaseHintRoutingEngine in project sharding-jdbc by shardingjdbc.

the class DatabaseHintSQLRouter method route.

@Override
public // TODO insert SQL need parse gen key
SQLRouteResult route(final String logicSQL, final List<Object> parameters, final SQLStatement sqlStatement) {
    SQLRouteResult result = new SQLRouteResult(sqlStatement);
    RoutingResult routingResult = new DatabaseHintRoutingEngine(shardingRule.getDataSourceNames(), (HintShardingStrategy) shardingRule.getDefaultDatabaseShardingStrategy()).route();
    for (TableUnit each : routingResult.getTableUnits().getTableUnits()) {
        result.getExecutionUnits().add(new SQLExecutionUnit(each.getDataSourceName(), logicSQL));
    }
    if (showSQL) {
        SQLLogger.logSQL(logicSQL, sqlStatement, result.getExecutionUnits(), parameters);
    }
    return result;
}
Also used : RoutingResult(io.shardingjdbc.core.routing.type.RoutingResult) DatabaseHintRoutingEngine(io.shardingjdbc.core.routing.type.hint.DatabaseHintRoutingEngine) SQLRouteResult(io.shardingjdbc.core.routing.SQLRouteResult) SQLExecutionUnit(io.shardingjdbc.core.routing.SQLExecutionUnit) TableUnit(io.shardingjdbc.core.routing.type.TableUnit) HintShardingStrategy(io.shardingjdbc.core.routing.strategy.hint.HintShardingStrategy)

Aggregations

SQLExecutionUnit (io.shardingjdbc.core.routing.SQLExecutionUnit)1 SQLRouteResult (io.shardingjdbc.core.routing.SQLRouteResult)1 HintShardingStrategy (io.shardingjdbc.core.routing.strategy.hint.HintShardingStrategy)1 RoutingResult (io.shardingjdbc.core.routing.type.RoutingResult)1 TableUnit (io.shardingjdbc.core.routing.type.TableUnit)1 DatabaseHintRoutingEngine (io.shardingjdbc.core.routing.type.hint.DatabaseHintRoutingEngine)1