Example usage for javax.persistence NoResultException printStackTrace

List of usage examples for javax.persistence NoResultException printStackTrace

Introduction

In this page you can find the example usage for javax.persistence NoResultException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.cimpoint.mes.server.repositories.BatchRepository.java

@SuppressWarnings("unchecked")
public List<String> findBatchByWorkOrderNumber(String workOrderNumber) throws Exception {
    try {//from ww w  .  ja  va 2s .  c o  m
        List<String> list = (List<String>) getEntityManager()
                .createQuery("select o.number from EBatch o where o.workOrderNumber = ?1")
                .setParameter(1, workOrderNumber).getResultList();
        return list;
    } catch (NoResultException ex) {
        return new ArrayList<String>();
    } catch (Exception ex) {
        ex.printStackTrace();
        throw ex;
    }
}

From source file:com.cimpoint.mes.server.repositories.ContainerRepository.java

@SuppressWarnings("unchecked")
public List<String> findContainersByWorkOrderItemNumber(String workOrderItemNumber) throws Exception {
    try {/*w  w w  . j  a  v  a 2s .c o  m*/
        List<String> list = (List<String>) getEntityManager()
                .createQuery("select o.number from EContainer o where o.workOrderItemNumber = ?1")
                .setParameter(1, workOrderItemNumber).getResultList();
        return list;
    } catch (NoResultException ex) {
        return new ArrayList<String>();
    } catch (Exception ex) {
        ex.printStackTrace();
        throw ex;
    }
}

From source file:com.cimpoint.mes.server.repositories.ContainerRepository.java

@SuppressWarnings("unchecked")
public List<String> findContainerByWorkOrderNumber(String workOrderNumber) throws Exception {
    try {/*from w  w w . j a  v  a 2 s.  co  m*/
        List<String> list = (List<String>) getEntityManager()
                .createQuery("select o.number from EContainer o where o.workOrderNumber = ?1")
                .setParameter(1, workOrderNumber).getResultList();
        return list;
    } catch (NoResultException ex) {
        return new ArrayList<String>();
    } catch (Exception ex) {
        ex.printStackTrace();
        throw ex;
    }
}

From source file:com.cimpoint.mes.server.repositories.ContainerRepository.java

@SuppressWarnings("unchecked")
public Set<EContainer> findContainersByWorkOrderNumber(String workOrderNumber) throws Exception {
    try {//from ww w .  jav  a  2s  .c o m
        Set<EContainer> list = (Set<EContainer>) getEntityManager()
                .createQuery("select o from EContainer o where o.workOrderNumber = ?1")
                .setParameter(1, workOrderNumber).getResultList();
        return list;
    } catch (NoResultException ex) {
        return new HashSet<EContainer>();
    } catch (Exception ex) {
        ex.printStackTrace();
        throw ex;
    }
}

From source file:com.cimpoint.mes.server.repositories.ContainerRepository.java

public String getNextContainerNumber() throws Exception {
    Query qry = getEntityManager().createQuery("select o from EContainer o order by o.number desc")
            .setMaxResults(1);/*from  www  .  ja va2  s  . c om*/
    try {
        EContainer c = (EContainer) qry.getSingleResult();
        return String.valueOf(Integer.parseInt(c.getNumber()) + 1);
    } catch (NoResultException ex) {
        return this.getInitContainerNumber();
    } catch (Exception ex) {
        ex.printStackTrace();
        throw ex;
    }
}

From source file:com.cimpoint.mes.server.repositories.ConsumptionRepository.java

@SuppressWarnings("unchecked")
public Set<EConsumption> findConsumptions(MESConstants.Object.Type objectType, Long objectId) throws Exception {
    try {//from   w w w  . java 2s .  c o  m
        Set<EConsumption> consumptions = (HashSet<EConsumption>) getEntityManager()
                .createQuery("select o from EConsumption o where o.objectType = ?1 and o.objectId = ?2")
                .setParameter(1, objectType.toString()).setParameter(2, objectId).getResultList();
        return consumptions;
    } catch (NoResultException ex) {
        return new HashSet<EConsumption>();
    } catch (Exception ex) {
        ex.printStackTrace();
        throw ex;
    }
}

From source file:com.cimpoint.mes.server.repositories.ConsumptionRepository.java

@SuppressWarnings("unchecked")
public Set<EConsumption> findConsumptions(MESConstants.Consumption.Type consumptionType,
        MESConstants.Object.Type objectType, Long objectId) throws Exception {
    try {//from ww  w .ja v  a 2  s  .c o  m
        Set<EConsumption> consumptions = (HashSet<EConsumption>) getEntityManager().createQuery(
                "select o from EConsumption o where o.consumptionType = ?1 and o.objectType = ?2 and o.objectId = ?3")
                .setParameter(1, consumptionType.toString()).setParameter(2, objectType.toString())
                .setParameter(3, objectId).getResultList();
        return consumptions;
    } catch (NoResultException ex) {
        return new HashSet<EConsumption>();
    } catch (Exception ex) {
        ex.printStackTrace();
        throw ex;
    }
}

From source file:com.cimpoint.mes.server.repositories.PartRepository.java

public EPart findPartByNameAndRevision(String partName, String partRevision) throws Exception {
    try {/*from w  w w  .j  a  v  a 2 s . c  om*/
        return (EPart) getEntityManager()
                .createQuery("select o from EPart o where o.name = ?1 and o.revision = ?2")
                .setParameter(1, partName).setParameter(2, partRevision).getSingleResult();
    } catch (NoResultException ex) {
        return null;
    } catch (Exception ex) {
        ex.printStackTrace();
        throw ex;
    }
}

From source file:com.cimpoint.mes.server.repositories.WorkOrderRepository.java

public EWorkOrder findWorkOrderByNumber(String woNumber) throws Exception {
    try {/*from w  ww  . j  ava2  s  .  c om*/
        EWorkOrder wo = (EWorkOrder) getEntityManager()
                .createQuery("select o from EWorkOrder o  where o.number = ?1").setParameter(1, woNumber)
                .getSingleResult();
        return wo;
    } catch (NoResultException ex) {
        return null;
    } catch (Exception ex) {
        ex.printStackTrace();
        throw ex;
    }
}

From source file:com.cimpoint.mes.server.repositories.WorkOrderRepository.java

public EWorkOrderItem findWorkOrderItemByNumber(String workOrderItemNumber) throws Exception {
    try {//from   w  ww.j ava2  s.co  m
        EWorkOrderItem woi = (EWorkOrderItem) getEntityManager()
                .createQuery("select o from EWorkOrderItem o  where o.number = ?1")
                .setParameter(1, workOrderItemNumber).getSingleResult();
        return woi;
    } catch (NoResultException ex) {
        return null;
    } catch (Exception ex) {
        ex.printStackTrace();
        throw ex;
    }
}