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.LotRepository.java

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

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

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

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

@SuppressWarnings("unchecked")
public List<String> findUnitsByLotNumber(String lotNumber) throws Exception {
    try {/*from  ww w. j a  v a  2  s  .c o m*/
        List<String> list = (List<String>) getEntityManager()
                .createQuery("select o.serialNumber from EUnit o where o.lot.number = ?1")
                .setParameter(1, lotNumber).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.LotRepository.java

public String getNextLotNumber() throws Exception {
    Query qry = getEntityManager().createQuery("select o from ELot o order by o.number desc").setMaxResults(1);
    try {//from ww  w. j  a v  a2  s  .  com
        ELot lot = (ELot) qry.getSingleResult();
        return String.valueOf(Integer.parseInt(lot.getNumber()) + 1);
    } catch (NoResultException ex) {
        return this.getInitLotNumber();
    } catch (Exception ex) {
        ex.printStackTrace();
        throw ex;
    }
}

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

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

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

@SuppressWarnings("unchecked")
public List<String> findLotNumbersByWorkOrderItemNumber(String workOrderItemNumber) throws Exception {
    try {/*w w  w.j ava  2 s.c o  m*/
        List<String> list = (List<String>) getEntityManager()
                .createQuery("select o.number from ELot 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.UnitRepository.java

public String getNextUnitSerialNumber() throws Exception {
    Query qry = getEntityManager().createQuery("select o from EUnit o order by o.serialNumber desc")
            .setMaxResults(1);//from w ww  .ja v a 2 s  .c  om
    try {
        EUnit Unit = (EUnit) qry.getSingleResult();
        return String.valueOf(Integer.parseInt(Unit.getSerialNumber()) + 1);
    } catch (NoResultException ex) {
        return this.getInitUnitSerialNumber();
    } catch (Exception ex) {
        ex.printStackTrace();
        throw ex;
    }
}

From source file:cz.fi.muni.pa165.presentation.layer.mvc.controllers.AlbumController.java

@RequestMapping(value = { "/findByID" }, method = RequestMethod.POST)
public String findByID(@ModelAttribute("searchDTO") AlbumSearchDTO formBean, BindingResult bindingResult,
        Model model, RedirectAttributes redirectAttributes, UriComponentsBuilder uriBuilder) {

    if (bindingResult.hasErrors()) {
        model.addAttribute("searchDTO", new AlbumSearchDTO());
        model.addAttribute("albums", albumFacade.findAll());
        model.addAttribute("musicians", musicianFacade.findAll());
        return "album/find";
    }/*from w w w . jav a  2  s.  c o m*/

    List<AlbumDTO> foundAlbums = new ArrayList<AlbumDTO>();
    try {
        AlbumDTO found = albumFacade.findById(formBean.getAlbumId());
        if (found != null) {
            foundAlbums.add(found);
        }
    } catch (NoResultException e) {
        e.printStackTrace();
    } finally {
        model.addAttribute("allAlbums", foundAlbums);
        return "album/list";
    }
}

From source file:cz.fi.muni.pa165.presentation.layer.mvc.controllers.AlbumController.java

@RequestMapping(value = { "/findByTitle" }, method = RequestMethod.POST)
public String findByTitle(@ModelAttribute("searchDTO") AlbumSearchDTO formBean, BindingResult bindingResult,
        Model model, RedirectAttributes redirectAttributes, UriComponentsBuilder uriBuilder) {

    if (bindingResult.hasErrors()) {
        model.addAttribute("searchDTO", new AlbumSearchDTO());
        model.addAttribute("albums", albumFacade.findAll());
        model.addAttribute("musicians", musicianFacade.findAll());
        return "album/find";
    }//w w w .  jav a2 s.c  o m

    List<AlbumDTO> foundAlbums = new ArrayList<AlbumDTO>();
    try {
        AlbumDTO found = albumFacade.findByTitle(formBean.getTitle());
        if (found != null) {
            foundAlbums.add(found);
        }
    } catch (NoResultException e) {
        e.printStackTrace();
    } finally {
        model.addAttribute("allAlbums", foundAlbums);
        return "album/list";
    }
}

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

@SuppressWarnings("unchecked")
public Set<EStep> findSteps(String routingName) {
    try {// w  w  w.  j av  a 2  s .com
        Query qry = getEntityManager().createQuery("select o from EStep o where o.routing.name = ?1")
                .setParameter(1, routingName);
        List<EStep> steps = (List<EStep>) qry.getResultList();
        return new HashSet<EStep>(steps);
    } catch (NoResultException ex) {
        return null;
    } catch (Exception ex) {
        ex.printStackTrace();
        return null;
    }
}