@Test public void testDeleteByFilters() { GroupInstanceModel groupInstance1 = newGroupInstance(); GroupInstanceModel groupInstance2 = newGroupInstance(); groupInstanceDao.insert(groupInstance1, groupInstance2); query(groupInstance1, 1); query(groupInstance2, 1); groupInstanceDao.deleteByFilters(Lists.newArrayList(groupInstance1, groupInstance2)); query(groupInstance1, 0); query(groupInstance2, 0); }
protected void deleteByFilters(final List<GroupInstanceModel> filters){ checkInsertOrUpdateArgument(filters); DataConfig.jdbcTemplate().batchUpdate("delete from service_group_instance where group_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 GroupInstanceModel filter = filters.get(i); ps.setLong(1, filter.getGroupId()); ps.setString(2, filter.getInstanceId()); } }); }
GroupInstanceDao { protected void deleteByFilters(final List<GroupInstanceModel> filters){ checkInsertOrUpdateArgument(filters); DataConfig.jdbcTemplate().batchUpdate("delete from service_group_instance where group_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 GroupInstanceModel filter = filters.get(i); ps.setLong(1, filter.getGroupId()); ps.setString(2, filter.getInstanceId()); } }); } }
GroupInstanceDao { protected void deleteByFilters(final List<GroupInstanceModel> filters){ checkInsertOrUpdateArgument(filters); DataConfig.jdbcTemplate().batchUpdate("delete from service_group_instance where group_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 GroupInstanceModel filter = filters.get(i); ps.setLong(1, filter.getGroupId()); ps.setString(2, filter.getInstanceId()); } }); } private  GroupInstanceDao(); }
GroupInstanceDao { protected void deleteByFilters(final List<GroupInstanceModel> filters){ checkInsertOrUpdateArgument(filters); DataConfig.jdbcTemplate().batchUpdate("delete from service_group_instance where group_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 GroupInstanceModel filter = filters.get(i); ps.setLong(1, filter.getGroupId()); ps.setString(2, filter.getInstanceId()); } }); } private  GroupInstanceDao(); List<GroupInstanceModel> query(); List<GroupInstanceModel> select(GroupInstanceModel filter); List<GroupInstanceModel> select(List<Long> groupIds); }
GroupInstanceDao { protected void deleteByFilters(final List<GroupInstanceModel> filters){ checkInsertOrUpdateArgument(filters); DataConfig.jdbcTemplate().batchUpdate("delete from service_group_instance where group_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 GroupInstanceModel filter = filters.get(i); ps.setLong(1, filter.getGroupId()); ps.setString(2, filter.getInstanceId()); } }); } private  GroupInstanceDao(); List<GroupInstanceModel> query(); List<GroupInstanceModel> select(GroupInstanceModel filter); List<GroupInstanceModel> select(List<Long> groupIds); static final GroupInstanceDao INSTANCE; }