public void destroy(Integer id) throws NonexistentEntityException {
EntityManager em = null;
try {
em = getEntityManager();
em.getTransaction().begin();
Tagcorrelations tagcorrelations;
try {
tagcorrelations = em.getReference(Tagcorrelations.class, id);
tagcorrelations.getId();
} catch (EntityNotFoundException enfe) {
throw new NonexistentEntityException("The tagcorrelations with id " + id + " no longer exists.", enfe);
}
Tag referencedTagId = tagcorrelations.getReferencedTagId();
if (referencedTagId != null) {
referencedTagId.getTagcorrelationsList().remove(tagcorrelations);
referencedTagId = em.merge(referencedTagId);
}
Tag mainTagId = tagcorrelations.getMainTagId();
if (mainTagId != null) {
mainTagId.getTagcorrelationsList().remove(tagcorrelations);
mainTagId = em.merge(mainTagId);
}
em.remove(tagcorrelations);