List of usage examples for javax.persistence NoResultException printStackTrace
public void printStackTrace()
From source file:com.cimpoint.mes.server.repositories.UnitRepository.java
public EUnit findUnitBySerialNumber(String unitSerialNumber) throws Exception { try {//www . j av a 2s .c o m EUnit Unit = (EUnit) getEntityManager().createQuery("select o from EUnit o where o.serialNumber = ?1") .setParameter(1, unitSerialNumber).getSingleResult(); return Unit; } catch (NoResultException ex) { return null; } catch (Exception ex) { ex.printStackTrace(); throw ex; } }
From source file:com.mycompany.login.filter.AutenticacaoFilter.java
/** * Metodos de acesso ao BD/* w w w . j av a 2 s . c o m*/ * * @param login * @param senha * @return */ public Usuario buscarUsuario(String login, String senha) throws IOException { em = factory.createEntityManager(); com.mycompany.login.bean.Usuario usuario = null; try { TypedQuery<Usuario> query = em.createQuery( "SELECT u FROM Usuario u WHERE u.login = :login AND u.senha = :senha", Usuario.class); query.setParameter("login", login); query.setParameter("senha", senha); usuario = (Usuario) query.getSingleResult(); } catch (NoResultException e) { System.out.println("DAO: No foi encontrado resultado!"); } catch (Exception e) { e.printStackTrace(); } finally { em.close(); } return usuario; }
From source file:com.cimpoint.mes.server.repositories.WorkOrderRepository.java
@SuppressWarnings("unchecked") public List<String> findWorkOrderItemsByWorkOrderNumber(String woNumber) throws Exception { try {//www . j a v a 2s.c om List<String> list = (List<String>) getEntityManager() .createQuery("select o.number from EWorkOrderItem o where o.workOrder.number = ?1") .setParameter(1, woNumber).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.PartRepository.java
@SuppressWarnings("unchecked") public Set<String> findAllPartNameWithRevisions() throws Exception { try {//w w w .j a v a2 s . c o m Set<String> strSet = new HashSet<String>(); Query qry = entityManager.createQuery("SELECT e FROM EPart e"); List<EPart> parts = (List<EPart>) qry.getResultList(); if (parts != null && parts.size() > 0) { for (EPart e : parts) { strSet.add(e.getName() + MESConstants.REV_FOR_TEXT + e.getRevision()); } } return strSet; } catch (NoResultException ex) { return new HashSet<String>(); } catch (Exception ex) { ex.printStackTrace(); return new HashSet<String>(); } }
From source file:com.cimpoint.mes.server.repositories.PartRepository.java
@SuppressWarnings("unchecked") public Set<String> findRevisionsByPartName(String partName) throws Exception { try {//from w ww.j av a 2 s.c o m Set<String> strSet = new HashSet<String>(); Query query = entityManager.createQuery("SELECT e FROM EPart e where e.name = ?1"); query.setParameter(1, partName); List<EPart> parts = (List<EPart>) query.getResultList(); if (parts != null && parts.size() > 0) { for (EPart e : parts) { strSet.add(e.getRevision()); } } return strSet; } catch (NoResultException ex) { return new HashSet<String>(); } catch (Exception ex) { ex.printStackTrace(); return new HashSet<String>(); } }
From source file:com.cimpoint.mes.server.repositories.WorkOrderRepository.java
public String getNextWorkOrderNumber() throws Exception { Query qry = getEntityManager().createQuery("select o from EWorkOrder o order by o.number desc") .setMaxResults(1);// www.j a v a 2 s . c o m try { EWorkOrder wo = (EWorkOrder) qry.getSingleResult(); return String.valueOf(Integer.parseInt(wo.getNumber()) + 1); } catch (NoResultException ex) { return this.getInitWorkOrderNumber(); } catch (Exception ex) { ex.printStackTrace(); throw ex; } }
From source file:com.cimpoint.mes.server.repositories.WorkOrderRepository.java
public String getNextWorkOrderItemNumber() throws Exception { Query qry = getEntityManager().createQuery("select o from EWorkOrderItem o order by o.number desc") .setMaxResults(1);//from w ww . ja va2 s . c o m try { EWorkOrderItem woi = (EWorkOrderItem) qry.getSingleResult(); return String.valueOf(Integer.parseInt(woi.getNumber()) + 1); } catch (NoResultException ex) { return this.getInitWorkOrderNumber(); } catch (Exception ex) { ex.printStackTrace(); throw ex; } }
From source file:cz.fi.muni.pa165.presentation.layer.mvc.controllers.GenreController.java
@RequestMapping(value = { "/findByID" }, method = RequestMethod.POST) public String findByID(@ModelAttribute("searchDTO") GenreSearchDTO formBean, BindingResult bindingResult, Model model, RedirectAttributes redirectAttributes, UriComponentsBuilder uriBuilder) { if (bindingResult.hasErrors()) { model.addAttribute("searchDTO", new GenreSearchDTO()); return "genre/find"; }/* w w w . j a v a2 s.c o m*/ List<GenreDTO> foundGenres = new ArrayList<GenreDTO>(); try { GenreDTO found = genreFacade.findGenreByID(formBean.getGenreId()); if (found != null) { foundGenres.add(found); } } catch (NoResultException e) { e.printStackTrace(); } finally { model.addAttribute("allGenres", foundGenres); return "genre/list"; } }
From source file:cz.fi.muni.pa165.presentation.layer.mvc.controllers.GenreController.java
@RequestMapping(value = { "/findByTitle" }, method = RequestMethod.POST) public String findByTitle(@ModelAttribute("searchDTO") GenreSearchDTO formBean, BindingResult bindingResult, Model model, RedirectAttributes redirectAttributes, UriComponentsBuilder uriBuilder) { if (bindingResult.hasErrors()) { model.addAttribute("searchDTO", new GenreSearchDTO()); return "genre/find"; }/*from w w w.j a va2s . co m*/ List<GenreDTO> foundGenres = new ArrayList<GenreDTO>(); try { GenreDTO found = genreFacade.findGenreByTitle(formBean.getTitle()); if (found != null) { foundGenres.add(found); } } catch (NoResultException e) { e.printStackTrace(); } finally { model.addAttribute("allGenres", foundGenres); return "genre/list"; } }
From source file:com.cimpoint.mes.server.repositories.LotRepository.java
@SuppressWarnings("unchecked") public Set<ELot> findSplittedLots(String originalLotNumber) throws Exception { try {/*from ww w . j a v a2 s.c o m*/ Set<ELot> lots = (Set<ELot>) getEntityManager() .createQuery("select o from ELot o where o.originalNumber = ?1") .setParameter(1, originalLotNumber).getResultList(); return lots; } catch (NoResultException ex) { return new HashSet<ELot>(); } catch (Exception ex) { ex.printStackTrace(); throw ex; } }