List of usage examples for javax.persistence Query getResultList
List getResultList();
From source file:cz.fi.muni.pa036.airticketbooking.dao.impl.SeatReservationDaoImpl.java
@Override public List<SeatReservation> getByTicket(Long ticket) { try {//from w ww . j a va2 s . com Query q = em.createQuery("FROM SeatReservation WHERE ticket_id=:ticket"); q.setParameter("ticket", ticket); List<SeatReservation> planes = q.getResultList(); return Collections.unmodifiableList(planes); } catch (PersistenceException | IllegalArgumentException ex) { throw new DataAccessException(ex.getMessage(), ex) { }; } }
From source file:com.jd.survey.dao.security.UserDAOImpl.java
@SuppressWarnings("unchecked") @Transactional// ww w . j a va 2 s.c o m public Set<User> searchByLogin(String login) throws DataAccessException { Query query = createNamedQuery("User.searchByLogin", -1, -1, "%" + login + "%"); return new LinkedHashSet<User>(query.getResultList()); }
From source file:com.jd.survey.dao.security.UserDAOImpl.java
@SuppressWarnings("unchecked") @Transactional//from w ww . ja va2 s . c o m public Set<User> searchByEmail(String email) throws DataAccessException { Query query = createNamedQuery("User.searchByEmail", -1, -1, "%" + email + "%"); return new LinkedHashSet<User>(query.getResultList()); }
From source file:eu.planets_project.tb.impl.persistency.TestbedServiceTemplatePersistencyImpl.java
public Map<String, TestbedServiceTemplate> getAllTBServiceIDAndTemplates() { Query query = manager.createQuery("from TestbedServiceTemplateImpl where discr='template'"); Iterator<TestbedServiceTemplate> itTemplates = query.getResultList().iterator(); Map<String, TestbedServiceTemplate> ret = new HashMap<String, TestbedServiceTemplate>(); while (itTemplates.hasNext()) { TestbedServiceTemplate template = itTemplates.next(); ret.put(template.getUUID(), template); }//from ww w . j av a 2 s .c om return ret; }
From source file:com.sapito.db.dao.AbstractDao.java
public List<T> findRange(int[] range) { javax.persistence.criteria.CriteriaQuery cq = entityManager.getCriteriaBuilder().createQuery(); cq.select(cq.from(entityClass));//from ww w .j a v a 2 s. c om javax.persistence.Query q = entityManager.createQuery(cq); q.setMaxResults(range[1] - range[0]); q.setFirstResult(range[0]); return q.getResultList(); }
From source file:org.simbasecurity.core.domain.repository.PolicyDatabaseRepository.java
@SuppressWarnings("unchecked") @Override//w ww. j a v a 2 s .c om public Collection<Policy> find(User user) { Query query = entityManager.createQuery("SELECT DISTINCT policy " + "FROM PolicyEntity policy " + "JOIN policy.roles role JOIN role.users user " + "WHERE user=:user"); query.setParameter("user", user); return query.getResultList(); }
From source file:bc8.movies.dao.UserDaoImpl.java
public List<Movie> getFavoriteMovies(User user) { Query query = em.createQuery( "select movie from Movie movie where movie.id in (select ref.movieId from UserMovieRef ref where ref.userId=" + user.getId() + ")"); return query.getResultList(); }
From source file:com.solace.data.jpa.GenericDao.java
/** * A simple clocking method/*www . j ava2 s .c o m*/ * * @param q * the query to execute * @return */ private List<E> executeList(javax.persistence.Query q) throws Exception { long now = System.currentTimeMillis(); List<E> list = (List<E>) q.getResultList(); LOGGER.debug(S_TOOK_D_MS_TO_EXECUTE_AND_RETURNED_D_ROWS, q.toString(), System.currentTimeMillis() - now, list.size()); return list; }
From source file:es.ucm.fdi.dalgs.user.repository.UserRepository.java
@SuppressWarnings("unchecked") public List<String> getAllByRole(String user_role) { Query query = em.createQuery("select u from User u join u.roles ur where ur.role = ?1 order by u.id"); query.setParameter(1, user_role);// w w w . j a va 2 s . c o m return query.getResultList(); }
From source file:org.kuali.mobility.push.dao.PreferenceDaoImpl.java
public List<Preference> findPreferencesByUsername(String username) { Query query = entityManager.createQuery("select p from Preference p where p.username = :username"); query.setParameter("username", username); return query.getResultList(); }