List of usage examples for javax.persistence Query getResultList
List getResultList();
From source file:com.expressui.core.dao.security.RoleDao.java
/** * Finds all Roles ordered by name.//from w ww.jav a2 s. co m * * @return all roles */ @Override public List<Role> findAll() { Query query = getEntityManager().createQuery("SELECT r FROM Role r ORDER BY r.name"); setReadOnly(query); return query.getResultList(); }
From source file:cz.muni.pa165.carparkapp.DAOImpl.EmployeeDAOImpl.java
@Override public Employee findEmployeeById(int id) { Validate.isTrue(id > 0, "Employees's ID cannot be null!"); Query query = em.createQuery("select e from Employee e " + "where e.id = ?1").setParameter(1, id); if (query.getResultList() == null) { throw new IllegalArgumentException("Error in query during employee finding"); }/*from w ww.j av a 2 s .c o m*/ if (query.getResultList().size() != 1) { throw new IllegalArgumentException("No such employee was found"); } return ((List<Employee>) query.getResultList()).get(0); }
From source file:net.chrissearle.flickrvote.dao.JpaImageDao.java
/** * Method getImagesWithRank will return all images with a given rank. * * @param rank of type long/*from ww w . ja va 2 s. co m*/ * @return Images with the given rank. */ @SuppressWarnings("unchecked") public List<Image> getImagesWithRank(long rank) { Query query = entityManager.createQuery("select i from Image i where i.finalRank = :rank"); query.setParameter("rank", rank); return (List<Image>) query.getResultList(); }
From source file:org.jrecruiter.dao.jpa.RegionDaoJpa.java
@SuppressWarnings("unchecked") public List<Region> getAllRegionsOrdered() { final List<Region> regions; final javax.persistence.Query query = entityManager .createQuery("select reg from Region reg " + "order by name ASC"); regions = query.getResultList(); return regions; }
From source file:org.osiam.auth.oauth_client.ClientDao.java
private ClientEntity getClientById(final String id) { final Query query = em.createNamedQuery("getClientById"); query.setParameter("id", id); final List<?> result = query.getResultList(); if (result.isEmpty()) { throw new ResourceNotFoundException("Resource " + id + " not found."); }/* w w w. j av a 2 s . c om*/ return (ClientEntity) result.get(0); }
From source file:org.syncope.core.persistence.dao.impl.ReportExecDAOImpl.java
@Override public List<ReportExec> findAll() { Query query = entityManager.createQuery("SELECT e FROM " + ReportExec.class.getSimpleName() + " e"); return query.getResultList(); }
From source file:com.sixsq.slipstream.persistence.Run.java
public static List<Run> listAll() throws ConfigurationException, ValidationException { EntityManager em = PersistenceUtil.createEntityManager(); Query q = createNamedQuery(em, "allRuns"); @SuppressWarnings("unchecked") List<Run> runs = q.getResultList(); em.close();//w w w. j a v a 2 s . c om return runs; }
From source file:com.brienwheeler.svc.users.impl.UserRoleDao.java
@Override @Transactional(readOnly = true, propagation = Propagation.SUPPORTS) @SuppressWarnings("unchecked") public List<UserRole> findByUser(User user) { Query query = entityManager.createQuery("from UserRole where user = :user"); query.setParameter("user", user); return (List<UserRole>) query.getResultList(); }
From source file:com.sct.descubriendoturuta.service.RutaServiceImpl.java
@Override @Transactional/*ww w.j a v a 2 s .c o m*/ public List<Ruta> obtenerRutas(int usuarioId) { Query query = em.createQuery("select r from Ruta r Where r.usuarioId = :p order by r.id desc"); query.setParameter("p", usuarioId); return query.getResultList(); }
From source file:com.nandhootoo.services.NoteServiceImpl.java
public List getNotesWithCriteria(String criteria) { try {/*www . j a va 2 s . c o m*/ Query aQuery = entityManager.createQuery("select note from Note as note " + criteria); return aQuery.getResultList(); } catch (Exception sqlex) { System.out.println("SQL Exception: " + sqlex.getMessage()); return null; } }