public void destroy(Long id) throws NonexistentEntityException {
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            SensorInfo sensorInfo;
            try {
                sensorInfo = em.getReference(SensorInfo.class, id);
                sensorInfo.getSensorId();
            } catch (EntityNotFoundException enfe) {
                throw new NonexistentEntityException("The sensorInfo with id " + id + " no longer exists.", enfe);
            }
            CustomerInfo relatedCustomerId = sensorInfo.getRelatedCustomerId();
            if (relatedCustomerId != null) {
                relatedCustomerId.getSensorInfoCollection().remove(sensorInfo);
                relatedCustomerId = em.merge(relatedCustomerId);
            }
            Collection<AlarmInfo> alarmInfoCollection = sensorInfo.getAlarmInfoCollection();
            for (AlarmInfo alarmInfoCollectionAlarmInfo : alarmInfoCollection) {
                alarmInfoCollectionAlarmInfo.setRelatedSensorId(null);
                alarmInfoCollectionAlarmInfo = em.merge(alarmInfoCollectionAlarmInfo);
            }
            em.remove(sensorInfo);
            em.getTransaction().commit();
        } finally {
            if (em != null) {
                em.close();
            }
        }
    }