@Override protected String getQuerySQL(String filter, SearchQueryConverter.ProcessedFilter where) { boolean containsWhereClause = getBaseSqlQuery().contains(" where "); return filter == null || filter.trim().length() == 0 ? getBaseSqlQuery() : getBaseSqlQuery() + (containsWhereClause ? " and " : " where ") + where.getSql(); }
@Override public int delete(String filter) { SearchQueryConverter.ProcessedFilter where = getQueryConverter().convert(filter, null, false); logger.debug("Filtering groups with SQL: " + where); try { String completeSql = "DELETE FROM " + getTableName() + " WHERE group_id IN (SELECT id FROM groups WHERE identity_zone_id='" + IdentityZoneHolder.get().getId() + "') AND " + where.getSql(); logger.debug("delete sql: " + completeSql + ", params: " + where.getParams()); return new NamedParameterJdbcTemplate(jdbcTemplate).update(completeSql, where.getParams()); } catch (DataAccessException e) { logger.debug("Filter '" + filter + "' generated invalid SQL", e); throw new IllegalArgumentException("Invalid delete filter: " + filter); } }