public void destroy(Long id) throws NonexistentEntityException {
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            AlarmInfo alarmInfo;
            try {
                alarmInfo = em.getReference(AlarmInfo.class, id);
                alarmInfo.getSerialNumber();
            } catch (EntityNotFoundException enfe) {
                throw new NonexistentEntityException("The alarmInfo with id " + id + " no longer exists.", enfe);
            }
            SensorInfo relatedSensorId = alarmInfo.getRelatedSensorId();
            if (relatedSensorId != null) {
                relatedSensorId.getAlarmInfoCollection().remove(alarmInfo);
                relatedSensorId = em.merge(relatedSensorId);
            }
            em.remove(alarmInfo);
            em.getTransaction().commit();
        } finally {
            if (em != null) {
                em.close();
            }
        }
    }