@Override public void removeMedia(Long id, MediaTypeEnum mediaType) { List<AccompanimentMedia> findBy = accompanimentMediaDAO.listByAccompaniment(id, mediaType.getId()); for (AccompanimentMedia accompanimentMedia : findBy) { accompanimentMedia.setAccompaniment(null); accompanimentMediaDAO.update(accompanimentMedia); } Accompaniment findById = accompanimentDAO.findById(id, null); if (MediaTypeEnum.PHOTO.equals(mediaType)) { findById.setPhotoName(null); accompanimentDAO.update(findById); } else if (MediaTypeEnum.VIDEO.equals(mediaType)) { findById.setVideoName(null); accompanimentDAO.update(findById); } }
@Override public void delete(Long id) { try { Accompaniment findById = accompanimentDAO.findById(id, null); deleteAssociations(findById); Accompaniment expurge = new Accompaniment(); expurge.setId(id); accompanimentDAO.update(expurge); accompanimentDAO.delete(expurge); } catch (Exception e) { LOGGER.error("DELETE ASSOCIATIONS ERROR ->> " + e); } }