Index: grails-app/services/com/lemans/ds/categoryspecialist/CategorySpecialistNotesManagerService.groovy =================================================================== diff -u -ra9b382fdfec1521b048308366f3449c2bf24f89f -rbd6b1ec39f40ee515066a0dcaf0d98cb9582e282 --- grails-app/services/com/lemans/ds/categoryspecialist/CategorySpecialistNotesManagerService.groovy (.../CategorySpecialistNotesManagerService.groovy) (revision a9b382fdfec1521b048308366f3449c2bf24f89f) +++ grails-app/services/com/lemans/ds/categoryspecialist/CategorySpecialistNotesManagerService.groovy (.../CategorySpecialistNotesManagerService.groovy) (revision bd6b1ec39f40ee515066a0dcaf0d98cb9582e282) @@ -52,7 +52,7 @@ softDelete(categorySpecialistNotes, username) if (!categorySpecialistNotes.hasErrors() && categorySpecialistNotes.mediaId) { deleteMediaEntity(categorySpecialistNotes.id, username) - deleteMedia(categorySpecialistNotes.mediaId, username) + deleteMedia(categorySpecialistNotes, username) } } categorySpecialistNotes @@ -77,8 +77,10 @@ sql().execute([now: now, user: username, entityId: categorySpecialistNoteId], MEDIA_ENTITY_DELETE_SQL) } - private void deleteMedia(Integer mediaId, String username) { + private void deleteMedia(CategorySpecialistNotes categorySpecialistNotes, String username) { Timestamp now = new Timestamp(new Date().time) - sql().execute([now: now, user: username, mediaId: mediaId], MEDIA_DELETE_SQL) + if (!CategorySpecialistNotes.findByMediaIdAndDateDeletedIsNull(categorySpecialistNotes.mediaId)) { + sql().execute([now: now, user: username, mediaId: categorySpecialistNotes.mediaId], MEDIA_DELETE_SQL) + } } }