public void destroy(Integer id) throws IllegalOrphanException, NonexistentEntityException, RollbackFailureException, Exception {
        EntityManager em = null;
        try {
            utx.begin();
            em = getEntityManager();
            TestcaseEntity testcaseEntity;
            try {
                testcaseEntity = em.getReference(TestcaseEntity.class, id);
                testcaseEntity.getTestcaseId();
            } catch (EntityNotFoundException enfe) {
                throw new NonexistentEntityException("The testcaseEntity with id " + id + " no longer exists.", enfe);
            }
            List<String> illegalOrphanMessages = null;
            List<TestrunEntity> testrunEntityListOrphanCheck = testcaseEntity.getTestrunEntityList();
            for (TestrunEntity testrunEntityListOrphanCheckTestrunEntity : testrunEntityListOrphanCheck) {
                if (illegalOrphanMessages == null) {
                    illegalOrphanMessages = new ArrayList<String>();
                }
                illegalOrphanMessages.add("This TestcaseEntity (" + testcaseEntity + ") cannot be destroyed since the TestrunEntity " + testrunEntityListOrphanCheckTestrunEntity + " in its testrunEntityList field has a non-nullable testcaseId field.");
            }
            if (illegalOrphanMessages != null) {
                throw new IllegalOrphanException(illegalOrphanMessages);
            }
            RequestEntity requestId = testcaseEntity.getRequestId();
            if (requestId != null) {
                requestId.getTestcaseEntityList().remove(testcaseEntity);
                requestId = em.merge(requestId);
            }
            ScriptEntity scriptId = testcaseEntity.getScriptId();
            if (scriptId != null) {
                scriptId.getTestcaseEntityList().remove(testcaseEntity);
                scriptId = em.merge(scriptId);
            }
            em.remove(testcaseEntity);
            utx.commit();
        } catch (Exception ex) {
            try {
                utx.rollback();
            } catch (Exception re) {
                throw new RollbackFailureException("An error occurred attempting to roll back the transaction.", re);
            }
            throw ex;
        } finally {
            if (em != null) {
                em.close();
            }
        }
    }