public void destroy(ItemstatPK id) throws NonexistentEntityException {
EntityManager em = null;
try {
em = getEntityManager();
em.getTransaction().begin();
Itemstat itemstat;
try {
itemstat = em.getReference(Itemstat.class, id);
itemstat.getItemstatPK();
} catch (EntityNotFoundException enfe) {
throw new NonexistentEntityException("The itemstat with id " + id + " no longer exists.", enfe);
}
Item item = itemstat.getItem();
if (item != null) {
item.getItemstatCollection().remove(itemstat);
item = em.merge(item);
}
em.remove(itemstat);