@Test public void testRelease() { for (RouteRuleGroupModel routeRuleGroup : newRouteRuleGroups()) { routeRuleGroupDao.insertOrUpdate(routeRuleGroup); RouteRuleGroupModel valueBeforeReleased = query(routeRuleGroup); assertRouteRuleGroup(routeRuleGroup, valueBeforeReleased); if (routeRuleGroup.getUnreleasedWeight() != null) { Assert.assertNull(valueBeforeReleased.getWeight()); Assert.assertNotEquals(routeRuleGroup.getUnreleasedWeight(), valueBeforeReleased.getWeight()); } else { Assert.assertEquals(routeRuleGroup.getUnreleasedWeight(), valueBeforeReleased.getWeight()); } routeRuleGroupDao.release(Lists.newArrayList(valueBeforeReleased)); RouteRuleGroupModel valueAfterReleased = query(routeRuleGroup); assertRouteRuleGroup(routeRuleGroup, valueAfterReleased); Assert.assertEquals(routeRuleGroup.getUnreleasedWeight(), valueAfterReleased.getWeight()); } }
protected void release(final List<RouteRuleGroupModel> models) { checkReleaseArgument(models); DataConfig.jdbcTemplate().batchUpdate("update service_route_rule_group set weight = unreleased_weight where route_rule_id=? and group_id=?", new BatchPreparedStatementSetter() { @Override public void setValues(PreparedStatement ps, int i) throws SQLException { RouteRuleGroupModel model = models.get(i); ps.setLong(1, model.getRouteRuleId()); ps.setLong(2, model.getGroupId()); } @Override public int getBatchSize() { return models.size(); } }); }
RouteRuleGroupDao { protected void release(final List<RouteRuleGroupModel> models) { checkReleaseArgument(models); DataConfig.jdbcTemplate().batchUpdate("update service_route_rule_group set weight = unreleased_weight where route_rule_id=? and group_id=?", new BatchPreparedStatementSetter() { @Override public void setValues(PreparedStatement ps, int i) throws SQLException { RouteRuleGroupModel model = models.get(i); ps.setLong(1, model.getRouteRuleId()); ps.setLong(2, model.getGroupId()); } @Override public int getBatchSize() { return models.size(); } }); } }
RouteRuleGroupDao { protected void release(final List<RouteRuleGroupModel> models) { checkReleaseArgument(models); DataConfig.jdbcTemplate().batchUpdate("update service_route_rule_group set weight = unreleased_weight where route_rule_id=? and group_id=?", new BatchPreparedStatementSetter() { @Override public void setValues(PreparedStatement ps, int i) throws SQLException { RouteRuleGroupModel model = models.get(i); ps.setLong(1, model.getRouteRuleId()); ps.setLong(2, model.getGroupId()); } @Override public int getBatchSize() { return models.size(); } }); }  }
RouteRuleGroupDao { protected void release(final List<RouteRuleGroupModel> models) { checkReleaseArgument(models); DataConfig.jdbcTemplate().batchUpdate("update service_route_rule_group set weight = unreleased_weight where route_rule_id=? and group_id=?", new BatchPreparedStatementSetter() { @Override public void setValues(PreparedStatement ps, int i) throws SQLException { RouteRuleGroupModel model = models.get(i); ps.setLong(1, model.getRouteRuleId()); ps.setLong(2, model.getGroupId()); } @Override public int getBatchSize() { return models.size(); } }); }  List<RouteRuleGroupModel> query(); RouteRuleGroupModel generateGroup(RouteRuleGroupModel routeRuleGroup); List<RouteRuleGroupModel> select(RouteRuleGroupModel filter); List<RouteRuleGroupModel> select(List<Long> groupIds); }
RouteRuleGroupDao { protected void release(final List<RouteRuleGroupModel> models) { checkReleaseArgument(models); DataConfig.jdbcTemplate().batchUpdate("update service_route_rule_group set weight = unreleased_weight where route_rule_id=? and group_id=?", new BatchPreparedStatementSetter() { @Override public void setValues(PreparedStatement ps, int i) throws SQLException { RouteRuleGroupModel model = models.get(i); ps.setLong(1, model.getRouteRuleId()); ps.setLong(2, model.getGroupId()); } @Override public int getBatchSize() { return models.size(); } }); }  List<RouteRuleGroupModel> query(); RouteRuleGroupModel generateGroup(RouteRuleGroupModel routeRuleGroup); List<RouteRuleGroupModel> select(RouteRuleGroupModel filter); List<RouteRuleGroupModel> select(List<Long> groupIds); static final RouteRuleGroupDao INSTANCE; }