List of usage examples for javax.persistence Query getResultList
List getResultList();
From source file:com.grummages.app.rest.entity.service.ListingRESTFacade.java
private List<Listing> find(boolean all, int maxResults, int firstResult) { try {//from ww w. j av a 2 s . c o m Query query = entityManager.createQuery("SELECT object(o) FROM Listing AS o"); if (!all) { query.setMaxResults(maxResults); query.setFirstResult(firstResult); } return query.getResultList(); } finally { entityManager.close(); } }
From source file:com.grummages.app.rest.entity.service.PaymentRESTFacade.java
private List<Payment> find(boolean all, int maxResults, int firstResult) { try {/* ww w . ja v a2 s . com*/ Query query = entityManager.createQuery("SELECT object(o) FROM Payment AS o"); if (!all) { query.setMaxResults(maxResults); query.setFirstResult(firstResult); } return query.getResultList(); } finally { entityManager.close(); } }
From source file:org.messic.server.datamodel.jpaimpl.DAOJPAUser.java
@Override @Transactional/*from w w w .j av a 2 s. c om*/ public List<MDOUser> getDLNAUsers() { Query query = entityManager.createQuery("from MDOUser as a where (a.allowDLNA = true)"); @SuppressWarnings("unchecked") List<MDOUser> results = query.getResultList(); return results; }
From source file:service.ItemRESTFacade.java
private List<Item> find(boolean all, int maxResults, int firstResult) { try {/*w w w . ja v a2 s . c o m*/ Query query = entityManager.createQuery("SELECT object(o) FROM Item AS o"); if (!all) { query.setMaxResults(maxResults); query.setFirstResult(firstResult); } return query.getResultList(); } finally { entityManager.close(); } }
From source file:fi.vm.sade.organisaatio.dao.impl.OrganisaatioNimiDAOImpl.java
@Override public OrganisaatioNimi findNimi(Organisaatio organisaatio, Date alkuPvm) { if (organisaatio == null) { throw new IllegalArgumentException("organisaatio cannot be null"); }//from ww w. j a v a 2s. co m LOG.info("findNimi({}, {})", new Object[] { organisaatio.getId(), alkuPvm }); // Kysely kokeilty mys QueryDsl:ll // Ongelmana oli se, ett pivmrn perusteella haku ei onnistunut jos // organisaation id:ll rivej oli enemmn kuin 1 DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); String s = "SELECT n FROM OrganisaatioNimi n " + "WHERE " + "organisaatio_id = " + organisaatio.getId() + " and " + "alkupvm = '" + df.format(alkuPvm) + "'"; Query q = getEntityManager().createQuery(s); List<OrganisaatioNimi> organisaatioNimet = (List<OrganisaatioNimi>) q.getResultList(); LOG.info("findNimi() result size: " + organisaatioNimet.size()); if (organisaatioNimet.size() == 1) { return organisaatioNimet.get(0); } LOG.info("findNimi({}, {}) --> OrganisaatioNimi not found", new Object[] { organisaatio.getId(), alkuPvm }); return null; }
From source file:service.ResourceRESTFacade.java
private List<Resource> find(boolean all, int maxResults, int firstResult) { try {/*from www . j av a2s.co m*/ Query query = entityManager.createQuery("SELECT object(o) FROM Resource AS o"); if (!all) { query.setMaxResults(maxResults); query.setFirstResult(firstResult); } return query.getResultList(); } finally { entityManager.close(); } }
From source file:com.cimpoint.mes.server.repositories.PartRepository.java
@SuppressWarnings("unchecked") public Set<String> findRevisionsByPartName(String partName) throws Exception { try {//from w w w . ja v a 2 s . co 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.sct.descubriendoturuta.service.UsuarioServiceImpl.java
@Override @Transactional//from w ww.j av a 2 s .c o m public List<Ruta> obtenerRutas(int usuarioId) { Query query = em.createQuery("select r from Ruta r Where r.usuario.id = :p order by r.id desc"); query.setParameter("p", usuarioId); return query.getResultList(); }
From source file:cz.fi.muni.pa165.dao.PrintedBookDAOImpl.java
@Override public List<PrintedBook> findAllBorrowedPrintedBooks() { try {/* ww w . ja v a 2 s. c o m*/ final Query query = em.createQuery("SELECT m FROM PrintedBook as m WHERE m.state = :i"); query.setParameter("i", Boolean.TRUE); return query.getResultList(); } catch (RuntimeException E) { throw new DAException(E.getMessage()); } }