### Question:
HibernateAttributeOptionDAO extends HibernatePersistentObjectDAO<AttributeOption> implements AttributeOptionDAO { @Override public void deleteOrphaned(long setId, Collection<String> currentAttributes) { try { if (currentAttributes == null || currentAttributes.isEmpty() || !checkStoringAspect()) return; StringBuffer buf = new StringBuffer(); for (String name : currentAttributes) { if (buf.length() == 0) buf.append("('"); else buf.append(",'"); buf.append(SqlUtil.doubleQuotes(name)); buf.append("'"); } buf.append(")"); List<AttributeOption> options = findByQuery( "from AttributeOption _opt where _opt.setId = ?1 and _opt.attribute not in " + buf.toString(), new Object[] { setId }, null); for (AttributeOption option : options) del(option, PersistentObject.DELETED_CODE_DEFAULT); } catch (Throwable e) { log.error(e.getMessage(), e); } } HibernateAttributeOptionDAO(); @Override boolean deleteBySetIdAndAttribute(long setId, String attribute); @Override List<AttributeOption> findBySetIdAndAttribute(long setId, String attribute); @Override boolean delete(long id, int code); @Override void deleteOrphaned(long setId, Collection<String> currentAttributes);  }### Answer:
@Test public void testDeleteOrphaned() { List<AttributeOption> options = dao.findBySetIdAndAttribute(1L, "att1"); Assert.assertEquals(2, options.size()); dao.deleteOrphaned(1L, (List<String>)Arrays.asList(new String[]{"pippo","pluto"})); options = dao.findBySetIdAndAttribute(1L, "att1"); Assert.assertEquals(0, options.size()); }