Search in sources :

Example 51 with EntityNotFoundException

use of javax.persistence.EntityNotFoundException in project OpenAttestation by OpenAttestation.

the class TblOemJpaController method destroy.

public void destroy(Integer id) throws NonexistentEntityException {
    EntityManager em = getEntityManager();
    try {
        em.getTransaction().begin();
        TblOem tblOem;
        try {
            tblOem = em.getReference(TblOem.class, id);
            tblOem.getId();
        } catch (EntityNotFoundException enfe) {
            throw new NonexistentEntityException("The tblOem with id " + id + " no longer exists.", enfe);
        }
        em.remove(tblOem);
        em.getTransaction().commit();
    } finally {
        em.close();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) TblOem(com.intel.mtwilson.as.data.TblOem) NonexistentEntityException(com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException) EntityNotFoundException(javax.persistence.EntityNotFoundException)

Example 52 with EntityNotFoundException

use of javax.persistence.EntityNotFoundException in project OpenAttestation by OpenAttestation.

the class TblTaLogJpaController method destroy.

public void destroy(Integer id) throws IllegalOrphanException, NonexistentEntityException {
    EntityManager em = getEntityManager();
    try {
        em.getTransaction().begin();
        TblTaLog tblTaLog;
        try {
            tblTaLog = em.getReference(TblTaLog.class, id);
            tblTaLog.getId();
        } catch (EntityNotFoundException enfe) {
            throw new NonexistentEntityException("The tblTaLog with id " + id + " no longer exists.", enfe);
        }
        em.remove(tblTaLog);
        em.getTransaction().commit();
    } finally {
        em.close();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) TblTaLog(com.intel.mtwilson.as.data.TblTaLog) NonexistentEntityException(com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException) EntityNotFoundException(javax.persistence.EntityNotFoundException)

Example 53 with EntityNotFoundException

use of javax.persistence.EntityNotFoundException in project OpenAttestation by OpenAttestation.

the class TblRequestQueueJpaController method destroy.

public void destroy(Integer id) throws NonexistentEntityException {
    EntityManager em = getEntityManager();
    try {
        em.getTransaction().begin();
        TblRequestQueue tblRequestQueue;
        try {
            tblRequestQueue = em.getReference(TblRequestQueue.class, id);
            tblRequestQueue.getId();
        } catch (EntityNotFoundException enfe) {
            throw new NonexistentEntityException("The tblRequestQueue with id " + id + " no longer exists.", enfe);
        }
        em.remove(tblRequestQueue);
        em.getTransaction().commit();
    } finally {
        em.close();
    }
}
Also used : TblRequestQueue(com.intel.mtwilson.as.data.TblRequestQueue) EntityManager(javax.persistence.EntityManager) NonexistentEntityException(com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException) EntityNotFoundException(javax.persistence.EntityNotFoundException)

Example 54 with EntityNotFoundException

use of javax.persistence.EntityNotFoundException in project API by ca-cwds.

the class AddressService method update.

@Override
public Response update(Serializable primaryKey, Request request) {
    assert primaryKey instanceof String;
    assert request instanceof gov.ca.cwds.rest.api.domain.cms.Address;
    gov.ca.cwds.rest.api.domain.cms.Address address = (gov.ca.cwds.rest.api.domain.cms.Address) request;
    try {
        String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
        Address managed = new Address((String) primaryKey, address, lastUpdatedId);
        managed = addressDao.update(managed);
        return new gov.ca.cwds.rest.api.domain.cms.Address(managed, true);
    } catch (EntityNotFoundException e) {
        LOGGER.info("Address not found : {}", address);
        throw new ServiceException(e);
    }
}
Also used : Address(gov.ca.cwds.data.persistence.cms.Address) PostedAddress(gov.ca.cwds.rest.api.domain.cms.PostedAddress) ServiceException(gov.ca.cwds.rest.services.ServiceException) EntityNotFoundException(javax.persistence.EntityNotFoundException)

Example 55 with EntityNotFoundException

use of javax.persistence.EntityNotFoundException in project API by ca-cwds.

the class AllegationService method update.

/**
   * {@inheritDoc}
   * 
   * @see gov.ca.cwds.rest.services.CrudsService#update(java.io.Serializable,
   *      gov.ca.cwds.rest.api.Request)
   */
@Override
public gov.ca.cwds.rest.api.domain.cms.Allegation update(Serializable primaryKey, Request request) {
    assert primaryKey instanceof String;
    assert request instanceof gov.ca.cwds.rest.api.domain.cms.Allegation;
    gov.ca.cwds.rest.api.domain.cms.Allegation allegation = (gov.ca.cwds.rest.api.domain.cms.Allegation) request;
    try {
        String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
        Allegation managed = new Allegation((String) primaryKey, allegation, lastUpdatedId);
        managed = allegationDao.update(managed);
        return new gov.ca.cwds.rest.api.domain.cms.Allegation(managed);
    } catch (EntityNotFoundException e) {
        LOGGER.info("Allegation not found : {}", allegation);
        throw new ServiceException(e);
    }
}
Also used : ServiceException(gov.ca.cwds.rest.services.ServiceException) PostedAllegation(gov.ca.cwds.rest.api.domain.cms.PostedAllegation) Allegation(gov.ca.cwds.data.persistence.cms.Allegation) EntityNotFoundException(javax.persistence.EntityNotFoundException)

Aggregations

EntityNotFoundException (javax.persistence.EntityNotFoundException)75 EntityManager (javax.persistence.EntityManager)20 NonexistentEntityException (com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException)18 ServiceException (gov.ca.cwds.rest.services.ServiceException)15 Transactional (org.springframework.transaction.annotation.Transactional)14 BusinessServiceException (sic.service.BusinessServiceException)11 Test (org.junit.Test)10 Calendar (java.util.Calendar)9 GregorianCalendar (java.util.GregorianCalendar)9 ArrayList (java.util.ArrayList)7 BooleanBuilder (com.querydsl.core.BooleanBuilder)6 TblMle (com.intel.mtwilson.as.data.TblMle)5 IllegalOrphanException (com.intel.mtwilson.as.controller.exceptions.IllegalOrphanException)4 TblModuleManifest (com.intel.mtwilson.as.data.TblModuleManifest)4 PersistenceException (javax.persistence.PersistenceException)4 Sort (org.springframework.data.domain.Sort)4 TblHosts (com.intel.mtwilson.as.data.TblHosts)3 OptimisticLockException (javax.persistence.OptimisticLockException)3 TblEventType (com.intel.mtwilson.as.data.TblEventType)2 TblHostSpecificManifest (com.intel.mtwilson.as.data.TblHostSpecificManifest)2