@Override public void removeAllPoolMessages(Set<Integer> proccessedIds) { if (proccessedIds == null || proccessedIds.isEmpty()) { return; } logger.debug("Removing poolMessages from db with ids: {}", proccessedIds); StringBuffer buffer = new StringBuffer(); buffer.append("delete from pn_pool_message where " + BeansUtils.prepareInSQLClause(new ArrayList<Integer>(proccessedIds), "id")); this.getJdbcTemplate().update(buffer.toString()); logger.debug("PoolMessages with id: {}, removed.", proccessedIds); }
/** * Create a string with set of IN clause. Every in clause has maximum 1000 ids. * Identifier means for what IN clause is calling (Like 'table.id') * * Reason for using is compatibility with oracle and other dbs. * * Example: " ( in (10,15,...) or in (...) or ... ) " * * @param beans list of perun beans * @return string with some sql IN clause */ public static String prepareInSQLClause(String identifier, List<? extends PerunBean> beans) { //get Ids List<Integer> beansIds = new ArrayList<>(); for(PerunBean pb: beans) { beansIds.add(pb.getId()); } return BeansUtils.prepareInSQLClause(beansIds, identifier); }