// delete comment from DB.
getEntityManager().createQuery("DELETE FROM Comment WHERE id = :commentId").setParameter("commentId",
inCommentId).executeUpdate();
Cache cache = getCache();
// delete commentDTO from cache.
cache.delete(CacheKeys.COMMENT_BY_ID + inCommentId);
// if present, update commentId list for activity in cache.
String commentsByActivityKey = CacheKeys.COMMENT_IDS_BY_ACTIVITY_ID + activityId;
cache.removeFromList(commentsByActivityKey, inCommentId);
// if present, update ActivityDTO in cache
String activityByIdKey = CacheKeys.ACTIVITY_BY_ID + activityId;
ActivityDTO activityDTO = (ActivityDTO) cache.get(activityByIdKey);
if (activityDTO != null)
{
List<Long> commentIds = cache.getList(commentsByActivityKey);
updateActivityDTO(activityDTO, inCommentId, commentIds);
getCache().set(activityByIdKey, activityDTO);
}
// update activity in search index