class IssueManager {

    @Transactional(propagation = Propagation.REQUIRED)
    public List<Issue> deleteIssuesForEntity(EntityVO entity) {
        validateEntityParameters(entity);
        validateEntityCanBeModified(entity);
        List<Issue> issuesToDelete = issueDao.loadIssuesForEntity(entity);
        if (CollectionUtils.isNotEmpty(issuesToDelete)) {
            List<Long> issuesIds = issuesToDelete.stream().map(Issue::getId).collect(Collectors.toList());

            List<Long> commentIds = commentDao.loadCommentsForIssues(issuesIds).values().stream()
                .flatMap(Collection::stream)
                .map(IssueComment::getId)
                .collect(Collectors.toList());

            List<Attachment> attachments = attachmentDao.loadAttachmentsByCommentIds(commentIds).values().stream()
                    .flatMap(Collection::stream)
                    .collect(Collectors.toList());
            attachments.addAll(attachmentDao.loadAttachmentsByIssueIds(issuesIds));
            attachmentFileManager.deleteAttachments(attachments);

            commentDao.deleteAllCommentsForIssuesList(issuesIds);
            issueDao.deleteIssuesForEntity(entity);
        }
        return issuesToDelete;
    }

}