Commit bef359cb authored by terrymanu's avatar terrymanu
Browse files

refactor

parent 02f31869
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -226,13 +226,13 @@ public final class StatementExecutor {
        postDMLExecutionEvents();
        if (1 == statementExecutorWrappers.size()) {
            StatementExecutorWrapper StatementExecutorWrapper = statementExecutorWrappers.iterator().next();
            boolean result = false;
            boolean result;
            try {
                result = executor.execute(StatementExecutorWrapper.getStatement(), StatementExecutorWrapper.getSqlExecutionUnit().getSql());
            } catch (final SQLException ex) {
                postDMLExecutionEventsAfterExecution(StatementExecutorWrapper, EventExecutionType.EXECUTE_FAILURE);
                ExecutorExceptionHandler.handleException(ex);
                return result;
                return false;
            } finally {
                MetricsContext.stop(context);
            }
@@ -243,13 +243,13 @@ public final class StatementExecutor {
        
            @Override
            public Boolean execute(final StatementExecutorWrapper input) throws Exception {
                boolean result = false;
                boolean result;
                try {
                    result = executor.execute(input.getStatement(), input.getSqlExecutionUnit().getSql());
                } catch (final SQLException ex) {
                    postDMLExecutionEventsAfterExecution(input, EventExecutionType.EXECUTE_FAILURE);
                    ExecutorExceptionHandler.handleException(ex);
                    return result;
                    return false;
                }
                postDMLExecutionEventsAfterExecution(input, EventExecutionType.EXECUTE_SUCCESS);
                return result;
+1 −1
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ public abstract class AbstractPreparedStatementAdapter extends AbstractUnsupport
    @Getter
    private final List<Object> parameters = new ArrayList<>();
    
    protected AbstractPreparedStatementAdapter(final ShardingConnection shardingConnection, final int resultSetType, final int resultSetConcurrency, final int resultSetHoldability) throws SQLException {
    protected AbstractPreparedStatementAdapter(final ShardingConnection shardingConnection, final int resultSetType, final int resultSetConcurrency, final int resultSetHoldability) {
        super(shardingConnection, resultSetType, resultSetConcurrency, resultSetHoldability);
    }
    
+6 −6
Original line number Diff line number Diff line
@@ -37,36 +37,36 @@ public final class SelectGroupByShardingDataBasesOnlyTest extends AbstractShardi
    @Test
    public void assertSelectSum() throws SQLException, DatabaseUnitException {
        String sql = "SELECT SUM(order_id) AS `orders_sum`, `user_id` FROM `t_order` GROUP BY `user_id`";
        assertDataSet("integrate/dataset/db/expect/select_groupby/SelectSum.xml", shardingDataSource.getConnection(), "t_order", sql);
        assertDataSet("integrate/dataset/db/expect/select_group_by/SelectSum.xml", shardingDataSource.getConnection(), "t_order", sql);
    }
    
    @Test
    public void assertSelectCount() throws SQLException, DatabaseUnitException {
        String sql = "SELECT COUNT(order_id) AS `orders_count`, `user_id` FROM `t_order` GROUP BY `user_id`";
        assertDataSet("integrate/dataset/db/expect/select_groupby/SelectCount.xml", shardingDataSource.getConnection(), "t_order", sql);
        assertDataSet("integrate/dataset/db/expect/select_group_by/SelectCount.xml", shardingDataSource.getConnection(), "t_order", sql);
    }
    
    @Test
    public void assertSelectMax() throws SQLException, DatabaseUnitException {
        String sql = "SELECT MAX(order_id) AS `max_order_id`, `user_id` FROM `t_order` GROUP BY `user_id`";
        assertDataSet("integrate/dataset/db/expect/select_groupby/SelectMax.xml", shardingDataSource.getConnection(), "t_order", sql);
        assertDataSet("integrate/dataset/db/expect/select_group_by/SelectMax.xml", shardingDataSource.getConnection(), "t_order", sql);
    }
    
    @Test
    public void assertSelectMin() throws SQLException, DatabaseUnitException {
        String sql = "SELECT MIN(order_id) AS `min_order_id`, `user_id` FROM `t_order` GROUP BY `user_id`";
        assertDataSet("integrate/dataset/db/expect/select_groupby/SelectMin.xml", shardingDataSource.getConnection(), "t_order", sql);
        assertDataSet("integrate/dataset/db/expect/select_group_by/SelectMin.xml", shardingDataSource.getConnection(), "t_order", sql);
    }
    
    @Test
    public void assertSelectAvg() throws SQLException, DatabaseUnitException {
        String sql = "SELECT AVG(order_id) AS `orders_avg`, `user_id` FROM `t_order` GROUP BY `user_id`";
        assertDataSet("integrate/dataset/db/expect/select_groupby/SelectAvg.xml", shardingDataSource.getConnection(), "t_order", sql);
        assertDataSet("integrate/dataset/db/expect/select_group_by/SelectAvg.xml", shardingDataSource.getConnection(), "t_order", sql);
    }
    
    @Test
    public void assertSelectOrderByDesc() throws SQLException, DatabaseUnitException {
        String sql = "SELECT SUM(order_id) AS `orders_sum`, `user_id` FROM `t_order` GROUP BY `user_id` ORDER BY orders_sum DESC";
        assertDataSet("integrate/dataset/db/expect/select_groupby/SelectOrderByDesc.xml", shardingDataSource.getConnection(), "t_order", sql);
        assertDataSet("integrate/dataset/db/expect/select_group_by/SelectOrderByDesc.xml", shardingDataSource.getConnection(), "t_order", sql);
    }
}
+6 −6
Original line number Diff line number Diff line
@@ -37,36 +37,36 @@ public final class SelectGroupByShardingBothDataBasesAndTablesTest extends Abstr
    @Test
    public void assertSelectSum() throws SQLException, DatabaseUnitException {
        String sql = "SELECT SUM(order_id) AS `orders_sum`, `user_id` FROM `t_order` GROUP BY `user_id`";
        assertDataSet("integrate/dataset/dbtbl/expect/select_groupby/SelectSum.xml", shardingDataSource.getConnection(), "t_order", sql);
        assertDataSet("integrate/dataset/dbtbl/expect/select_group_by/SelectSum.xml", shardingDataSource.getConnection(), "t_order", sql);
    }
    
    @Test
    public void assertSelectCount() throws SQLException, DatabaseUnitException {
        String sql = "SELECT COUNT(order_id) AS `orders_count`, `user_id` FROM `t_order` GROUP BY `user_id`";
        assertDataSet("integrate/dataset/dbtbl/expect/select_groupby/SelectCount.xml", shardingDataSource.getConnection(), "t_order", sql);
        assertDataSet("integrate/dataset/dbtbl/expect/select_group_by/SelectCount.xml", shardingDataSource.getConnection(), "t_order", sql);
    }
    
    @Test
    public void assertSelectMax() throws SQLException, DatabaseUnitException {
        String sql = "SELECT MAX(order_id) AS `max_order_id`, `user_id` FROM `t_order` GROUP BY `user_id`";
        assertDataSet("integrate/dataset/dbtbl/expect/select_groupby/SelectMax.xml", shardingDataSource.getConnection(), "t_order", sql);
        assertDataSet("integrate/dataset/dbtbl/expect/select_group_by/SelectMax.xml", shardingDataSource.getConnection(), "t_order", sql);
    }
    
    @Test
    public void assertSelectMin() throws SQLException, DatabaseUnitException {
        String sql = "SELECT MIN(order_id) AS `min_order_id`, `user_id` FROM `t_order` GROUP BY `user_id`";
        assertDataSet("integrate/dataset/dbtbl/expect/select_groupby/SelectMin.xml", shardingDataSource.getConnection(), "t_order", sql);
        assertDataSet("integrate/dataset/dbtbl/expect/select_group_by/SelectMin.xml", shardingDataSource.getConnection(), "t_order", sql);
    }
    
    @Test
    public void assertSelectAvg() throws SQLException, DatabaseUnitException {
        String sql = "SELECT AVG(order_id) AS `orders_avg`, `user_id` FROM `t_order` GROUP BY `user_id`";
        assertDataSet("integrate/dataset/dbtbl/expect/select_groupby/SelectAvg.xml", shardingDataSource.getConnection(), "t_order", sql);
        assertDataSet("integrate/dataset/dbtbl/expect/select_group_by/SelectAvg.xml", shardingDataSource.getConnection(), "t_order", sql);
    }
    
    @Test
    public void assertSelectOrderByDesc() throws SQLException, DatabaseUnitException {
        String sql = "SELECT SUM(order_id) AS `orders_sum`, `user_id` FROM `t_order` GROUP BY `user_id` ORDER BY orders_sum DESC";
        assertDataSet("integrate/dataset/dbtbl/expect/select_groupby/SelectOrderByDesc.xml", shardingDataSource.getConnection(), "t_order", sql);
        assertDataSet("integrate/dataset/dbtbl/expect/select_group_by/SelectOrderByDesc.xml", shardingDataSource.getConnection(), "t_order", sql);
    }
}
+6 −6
Original line number Diff line number Diff line
@@ -37,36 +37,36 @@ public final class SelectGroupByShardingTablesOnlyTest extends AbstractShardingT
    @Test
    public void assertSelectSum() throws SQLException, DatabaseUnitException {
        String sql = "SELECT SUM(order_id) AS `orders_sum`, `user_id` FROM `t_order` GROUP BY `user_id`";
        assertDataSet("integrate/dataset/tbl/expect/select_groupby/SelectSum.xml", shardingDataSource.getConnection(), "t_order", sql);
        assertDataSet("integrate/dataset/tbl/expect/select_group_by/SelectSum.xml", shardingDataSource.getConnection(), "t_order", sql);
    }
    
    @Test
    public void assertSelectCount() throws SQLException, DatabaseUnitException {
        String sql = "SELECT COUNT(order_id) AS `orders_count`, `user_id` FROM `t_order` GROUP BY `user_id`";
        assertDataSet("integrate/dataset/tbl/expect/select_groupby/SelectCount.xml", shardingDataSource.getConnection(), "t_order", sql);
        assertDataSet("integrate/dataset/tbl/expect/select_group_by/SelectCount.xml", shardingDataSource.getConnection(), "t_order", sql);
    }
    
    @Test
    public void assertSelectMax() throws SQLException, DatabaseUnitException {
        String sql = "SELECT MAX(order_id) AS `max_order_id`, `user_id` FROM `t_order` GROUP BY `user_id`";
        assertDataSet("integrate/dataset/tbl/expect/select_groupby/SelectMax.xml", shardingDataSource.getConnection(), "t_order", sql);
        assertDataSet("integrate/dataset/tbl/expect/select_group_by/SelectMax.xml", shardingDataSource.getConnection(), "t_order", sql);
    }
    
    @Test
    public void assertSelectMin() throws SQLException, DatabaseUnitException {
        String sql = "SELECT MIN(order_id) AS `min_order_id`, `user_id` FROM `t_order` GROUP BY `user_id`";
        assertDataSet("integrate/dataset/tbl/expect/select_groupby/SelectMin.xml", shardingDataSource.getConnection(), "t_order", sql);
        assertDataSet("integrate/dataset/tbl/expect/select_group_by/SelectMin.xml", shardingDataSource.getConnection(), "t_order", sql);
    }
    
    @Test
    public void assertSelectAvg() throws SQLException, DatabaseUnitException {
        String sql = "SELECT AVG(order_id) AS `orders_avg`, `user_id` FROM `t_order` GROUP BY `user_id`";
        assertDataSet("integrate/dataset/tbl/expect/select_groupby/SelectAvg.xml", shardingDataSource.getConnection(), "t_order", sql);
        assertDataSet("integrate/dataset/tbl/expect/select_group_by/SelectAvg.xml", shardingDataSource.getConnection(), "t_order", sql);
    }
    
    @Test
    public void assertSelectOrderByDesc() throws SQLException, DatabaseUnitException {
        String sql = "SELECT SUM(order_id) AS `orders_sum`, `user_id` FROM `t_order` GROUP BY `user_id` ORDER BY orders_sum DESC";
        assertDataSet("integrate/dataset/tbl/expect/select_groupby/SelectOrderByDesc.xml", shardingDataSource.getConnection(), "t_order", sql);
        assertDataSet("integrate/dataset/tbl/expect/select_group_by/SelectOrderByDesc.xml", shardingDataSource.getConnection(), "t_order", sql);
    }
}
Loading