@Test public void testDeleteByFilters() throws Exception { ServiceInstanceModel serviceInstance1 = newServiceInstance(); ServiceInstanceModel serviceInstance2 = newServiceInstance(); serviceInstanceDao.insertOrUpdate(serviceInstance1, serviceInstance2); query(serviceInstance1, 1); query(serviceInstance2, 1); serviceInstanceDao.deleteByFilters(Lists.newArrayList(serviceInstance1, serviceInstance2)); query(serviceInstance1, 0); query(serviceInstance2, 0); }
protected void deleteByFilters(final List<ServiceInstanceModel> filters) { checkInsertOrUpdateArgument(filters); DataConfig.jdbcTemplate().batchUpdate("delete from service_instance where service_id = ? and instance_id=?", new BatchPreparedStatementSetter() { @Override public int getBatchSize() { return filters.size(); } @Override public void setValues(final PreparedStatement ps, final int i) throws SQLException { final ServiceInstanceModel filter = filters.get(i); ps.setString(1, filter.getServiceId()); ps.setString(2, filter.getInstanceId()); } }); }
ServiceInstanceDao { protected void deleteByFilters(final List<ServiceInstanceModel> filters) { checkInsertOrUpdateArgument(filters); DataConfig.jdbcTemplate().batchUpdate("delete from service_instance where service_id = ? and instance_id=?", new BatchPreparedStatementSetter() { @Override public int getBatchSize() { return filters.size(); } @Override public void setValues(final PreparedStatement ps, final int i) throws SQLException { final ServiceInstanceModel filter = filters.get(i); ps.setString(1, filter.getServiceId()); ps.setString(2, filter.getInstanceId()); } }); } }
ServiceInstanceDao { protected void deleteByFilters(final List<ServiceInstanceModel> filters) { checkInsertOrUpdateArgument(filters); DataConfig.jdbcTemplate().batchUpdate("delete from service_instance where service_id = ? and instance_id=?", new BatchPreparedStatementSetter() { @Override public int getBatchSize() { return filters.size(); } @Override public void setValues(final PreparedStatement ps, final int i) throws SQLException { final ServiceInstanceModel filter = filters.get(i); ps.setString(1, filter.getServiceId()); ps.setString(2, filter.getInstanceId()); } }); } private  ServiceInstanceDao(); }
ServiceInstanceDao { protected void deleteByFilters(final List<ServiceInstanceModel> filters) { checkInsertOrUpdateArgument(filters); DataConfig.jdbcTemplate().batchUpdate("delete from service_instance where service_id = ? and instance_id=?", new BatchPreparedStatementSetter() { @Override public int getBatchSize() { return filters.size(); } @Override public void setValues(final PreparedStatement ps, final int i) throws SQLException { final ServiceInstanceModel filter = filters.get(i); ps.setString(1, filter.getServiceId()); ps.setString(2, filter.getInstanceId()); } }); } private  ServiceInstanceDao(); List<ServiceInstanceModel> query(); List<ServiceInstanceModel> select(ServiceInstanceModel filter); List<ServiceInstanceModel> select(List<Long> groupIds); }
ServiceInstanceDao { protected void deleteByFilters(final List<ServiceInstanceModel> filters) { checkInsertOrUpdateArgument(filters); DataConfig.jdbcTemplate().batchUpdate("delete from service_instance where service_id = ? and instance_id=?", new BatchPreparedStatementSetter() { @Override public int getBatchSize() { return filters.size(); } @Override public void setValues(final PreparedStatement ps, final int i) throws SQLException { final ServiceInstanceModel filter = filters.get(i); ps.setString(1, filter.getServiceId()); ps.setString(2, filter.getInstanceId()); } }); } private  ServiceInstanceDao(); List<ServiceInstanceModel> query(); List<ServiceInstanceModel> select(ServiceInstanceModel filter); List<ServiceInstanceModel> select(List<Long> groupIds); static final ServiceInstanceDao INSTANCE; }