Example usage for javax.persistence EntityNotFoundException getMessage

List of usage examples for javax.persistence EntityNotFoundException getMessage

Introduction

In this page you can find the example usage for javax.persistence EntityNotFoundException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:io.syndesis.rest.v1.handler.exception.EntityNotFoundExceptionMapper.java

@Override
protected String developerMessage(final EntityNotFoundException exception) {
    return "Entity Not Found Exception " + exception.getMessage();
}

From source file:io.hops.hopsworks.common.dao.certificates.CertsFacade.java

public List<ProjectGenericUserCerts> findAllProjectGenericUserCerts() {
    TypedQuery<ProjectGenericUserCerts> query = em.createNamedQuery("ProjectGenericUserCerts.findAll",
            ProjectGenericUserCerts.class);

    try {/*from  w w w .jav a 2  s  .com*/
        return query.getResultList();
    } catch (EntityNotFoundException ex) {
        LOG.log(Level.SEVERE, ex.getMessage(), ex);
    } catch (NoResultException ex) {

    }
    return new ArrayList<>();
}

From source file:net.navasoft.madcoin.backend.model.controller.impl.WorkRequestDataAccess.java

/**
 * Pre construct.//from ww  w  . java 2s . co m
 * 
 * @param toInsert
 *            the to insert
 * @since 2/09/2014, 09:31:40 PM
 */
@Override
public void preConstruct(WorkRequests toInsert) {
    if (toInsert.getWorkRequestsPK() == null) {
        toInsert.setWorkRequestsPK(new WorkRequestsPK());
    }
    if (toInsert.getWorkRequestsXEndUsersCollection() == null) {
        toInsert.setWorkRequestsXEndUsersCollection(new ArrayList<WorkRequestsXEndUsers>());
    }
    if (toInsert.getWorkRequestsXServiceProvidersCollection() == null) {
        toInsert.setWorkRequestsXServiceProvidersCollection(new ArrayList<WorkRequestsXServiceProviders>());
    }

    toInsert.getWorkRequestsPK().setCategoryId(toInsert.getServiceCategories().getIdServiceCategory());
    try {
        try {
            ServiceCategories serviceCategories = toInsert.getServiceCategories();
            if (serviceCategories != null) {
                serviceCategories = entityManager.getReference(serviceCategories.getClass(),
                        serviceCategories.getIdServiceCategory());
                toInsert.setServiceCategories(serviceCategories);
                storage.storeReference(WorkRequestStorageKeys.CATEGORY, ReferenceMode.NEW_REFERENCE,
                        serviceCategories);
            }
        } catch (EntityNotFoundException notfound) {
            System.out.println("categoria invalida");
            throw new NonexistentEntityException(notfound.getMessage());
        }

        // se hace posteriormente a la insercion de la orden...
        try {
            WorkRequestLocations workRequestLocations = toInsert.getWorkRequestLocations();
            if (workRequestLocations != null) {
                workRequestLocations = entityManager.getReference(workRequestLocations.getClass(),
                        workRequestLocations.getWorkRequestLocationsPK());
                toInsert.setWorkRequestLocations(workRequestLocations);
                storage.storeReference(WorkRequestStorageKeys.LOCATION, ReferenceMode.NEW_REFERENCE,
                        workRequestLocations);
            }
        } catch (EntityNotFoundException notfound) {
            System.out.println("localizacion invalida");
            throw new NonexistentEntityException(notfound.getMessage());
        }

    } catch (NonexistentEntityException ne) {
        throw new InconsistentDataException(ne.getMessage());
    }

    Collection<WorkRequestsXEndUsers> generationUsers = new ArrayList<WorkRequestsXEndUsers>();
    for (WorkRequestsXEndUsers genUser : toInsert.getWorkRequestsXEndUsersCollection()) {
        genUser = entityManager.getReference(genUser.getClass(), genUser.getWorkRequestsXEndUsersPK());
        generationUsers.add(genUser);
    }
    toInsert.setWorkRequestsXEndUsersCollection(generationUsers);
    storage.storeReference(WorkRequestStorageKeys.END_USER, ReferenceMode.NEW_REFERENCE, generationUsers);

    // Cuando se crea la orden no se ingresa el proveedor, sin embargo, hay
    // que revisar si otros tipos de usuario final pueden escoger
    // inmediatamente...
    Collection<WorkRequestsXServiceProviders> attendingProvs = new ArrayList<WorkRequestsXServiceProviders>();
    for (WorkRequestsXServiceProviders provider : toInsert.getWorkRequestsXServiceProvidersCollection()) {
        provider = entityManager.getReference(provider.getClass(),
                provider.getWorkRequestsXServiceProvidersPK());
        attendingProvs.add(provider);
    }
    toInsert.setWorkRequestsXServiceProvidersCollection(attendingProvs);
    storage.storeReference(WorkRequestStorageKeys.PROVIDER, ReferenceMode.NEW_REFERENCE, attendingProvs);
}

From source file:io.hops.hopsworks.common.util.Settings.java

/**
 * Get all variables from the database.// w w w.  j  a v  a2 s .  c o m
 *
 * @return List with all the variables
 */
public List<Variables> getAllVariables() {
    TypedQuery<Variables> query = em.createNamedQuery("Variables.findAll", Variables.class);

    try {
        return query.getResultList();
    } catch (EntityNotFoundException ex) {
        LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
    } catch (NoResultException ex) {
    }
    return new ArrayList<>();
}

From source file:org.kuali.rice.kew.routeheader.dao.impl.DocumentRouteHeaderDAOJpaImpl.java

public String getApplicationIdByDocumentId(String documentId) {
    if (documentId == null) {
        throw new IllegalArgumentException("Encountered a null document ID.");
    }//w w w .  j  a v a2 s  .  c  om

    String applicationId = null;

    try {
        String sql = "SELECT DT.APPL_ID FROM KREW_DOC_TYP_T DT, KREW_DOC_HDR_T DH "
                + "WHERE DH.DOC_TYP_ID=DT.DOC_TYP_ID AND " + "DH.DOC_HDR_ID=?";

        Query query = entityManager.createNativeQuery(sql);
        query.setParameter(1, documentId);

        applicationId = (String) query.getSingleResult();
    } catch (EntityNotFoundException enfe) {
        throw new WorkflowRuntimeException(enfe.getMessage());
    }

    return applicationId;
}

From source file:org.kuali.rice.kew.routeheader.dao.impl.DocumentRouteHeaderDAOJpaImpl.java

public Collection findByDocTypeAndAppId(String documentTypeName, String appId) {
    try {/*from   w  ww. j  a v a 2 s  . c om*/
        String sql = "SELECT DISTINCT " + "    (docHdr.doc_hdr_id) " + "FROM " + "    KREW_DOC_HDR_T docHdr, "
                + "    KREW_DOC_TYP_T docTyp " + "WHERE " + "    docHdr.APP_DOC_ID     = ? "
                + "    AND docHdr.DOC_TYP_ID = docTyp.DOC_TYP_ID " + "    AND docTyp.DOC_TYP_NM = ?";

        Query query = entityManager.createNativeQuery(sql);
        query.setParameter(1, appId);
        query.setParameter(2, documentTypeName);
        Collection<Long> idCollection = new ArrayList<Long>();
        for (Object tempId : query.getResultList()) {
            idCollection.add(((BigDecimal) tempId).longValueExact());
        }
        return idCollection;
    } catch (EntityNotFoundException enfe) {
        throw new WorkflowRuntimeException(enfe.getMessage());
    }
}

From source file:org.rhq.enterprise.server.measurement.MeasurementDefinitionManagerBean.java

/**
 * Remove the given definition with its attached schedules.
 *
 * @param def the MeasuremendDefinition to delete
 */// w  w  w .j  a  v  a2 s  .  co m
public void removeMeasurementDefinition(MeasurementDefinition def) {
    // First remove the schedules and associated OOBs.
    List<MeasurementSchedule> schedules = def.getSchedules();
    Iterator<MeasurementSchedule> schedIter = schedules.iterator();
    while (schedIter.hasNext()) {
        MeasurementSchedule sched = schedIter.next();
        if (sched.getBaseline() != null) {
            entityManager.remove(sched.getBaseline());
            sched.setBaseline(null);
        }
        oobManager.removeOOBsForSchedule(subjectManager.getOverlord(), sched);
        sched.getResource().setAgentSynchronizationNeeded();
        entityManager.remove(sched);
        schedIter.remove();
    }

    // Now remove the definition itself.
    try {
        if ((def.getId() != 0) && entityManager.contains(def)) {
            entityManager.remove(def);
        }
    } catch (EntityNotFoundException enfe) {
        if (log.isDebugEnabled()) {
            log.debug("Definition # " + def.getId() + " not found: " + enfe.getMessage());
        }
    } catch (PersistenceException pe) {
        if (log.isDebugEnabled()) {
            log.debug("Exception when deleting Definition # " + def.getId() + ": " + pe.getMessage());
        }
    } catch (Exception e) {
        log.warn(e.fillInStackTrace());
    }
}