List of usage examples for javax.persistence Query getResultList
List getResultList();
From source file:org.syncope.core.persistence.dao.impl.RoleDAOImpl.java
@Override public List<SyncopeRole> findAll() { Query query = entityManager.createQuery("SELECT e FROM SyncopeRole e"); return query.getResultList(); }
From source file:com.impetus.kwitter.service.TwitterService.java
@Override public List<User> getAllUsers() { Query q = em.createQuery("select u from User u"); List<User> users = q.getResultList(); return users; }
From source file:com.expressui.core.dao.security.PermissionDao.java
/** * Finds all permissions for a given role. * * @param role role to query/*from w ww . j a va 2s .com*/ * @return all permissions for role */ public List<Permission> findByRole(Role role) { Query query = getEntityManager().createQuery("SELECT p FROM Permission p WHERE p.role = :role"); query.setParameter("role", role); return query.getResultList(); }
From source file:com.gerenciaProyecto.DaoImple.UsuarioDaoImpl.java
@Override public List<Usuario> listar() { EntityManager em = getEntityManager(); List<Usuario> lista = new ArrayList<Usuario>(); Query q = em.createQuery("SELECT u FROM Usuario u where u.estado= :estado "); q.setParameter("estado", Usuario.ESTADOS.ACTIVO.getEstado()); lista = q.getResultList(); return lista; }
From source file:com.telefonica.euro_iaas.commons.properties.impl.PropertiesDAOJPAImpl.java
/** * @see PropertiesDAO#load(String)/*from ww w . j a va2 s. c om*/ */ public Properties load(String namespace) { Properties prop = new Properties(); Query query = entityManager.createQuery(FIND_BY_NAMESPACE); query.setParameter(NAMESPACE, namespace); for (Iterator i = query.getResultList().iterator(); i.hasNext();) { PersistentProperty p = (PersistentProperty) i.next(); prop.setProperty(p.getKey(), p.getValue()); } return prop; }
From source file:vlove.dao.impl.GenericDaoImpl.java
/** * @see vlove.dao.GenericDao#query(String, Map) *//*from w ww . j av a 2s . co m*/ @Override public <T> List<T> query(String query, Map<String, Object> parameters) { Query q = em.createQuery(query); applyParameters(q, parameters); return q.getResultList(); }
From source file:web.org.perfmon4j.console.app.UsersController.java
@SuppressWarnings("unchecked") private Collection<User> getAllUsers() { Query q = em.createQuery("select u from User u order by u.userName"); return (Collection<User>) q.getResultList(); }
From source file:com.eu.evaluation.server.dao.DefaultDAO.java
/** * ??//from w w w .j a v a 2 s . com * @param jpql * @param params * @return */ public <T> T findOnylFirst(String jpql, MapSqlParameterSource params) { Query query = this.createQuery(jpql, params); query.setFirstResult(0); query.setMaxResults(1); List<T> result = query.getResultList(); if (result.isEmpty()) { return null; } else { return result.get(0); } }
From source file:boutiqueEnLigne.service.ArticleService2.java
public List<Article> findByGenreOrderByPrixAsc(Genre genre) { if (genre == Genre.ENFANT) { Query query = em.createQuery("SELECT a FROM Article a WHERE a.genre =:mon_genre"); query.setParameter("mon_genre", Genre.ENFANT); return query.getResultList(); }/* w w w .j a v a 2s . c om*/ if (genre == Genre.FEMME) { Query query = em.createQuery("SELECT a FROM Article a WHERE a.genre =:mon_genre"); query.setParameter("mon_genre", Genre.FEMME); Query query2 = em.createQuery("SELECT a FROM Article a WHERE a.genre =:mon_genre2"); query2.setParameter("mon_genre2", Genre.MIXTE); List<Article> articles = new ArrayList<>(); articles = query.getResultList(); List<Article> articles2 = new ArrayList<>(); articles2 = query2.getResultList(); articles2.addAll(articles); return articles2; } if (genre == Genre.HOMME) { Query query = em.createQuery("SELECT a FROM Article a WHERE a.genre =:mon_genre"); query.setParameter("mon_genre", Genre.HOMME); Query query2 = em.createQuery("SELECT a FROM Article a WHERE a.genre =:mon_genre2"); query2.setParameter("mon_genre2", Genre.MIXTE); List<Article> articles = new ArrayList<>(); articles = query.getResultList(); List<Article> articles2 = new ArrayList<>(); articles2 = query2.getResultList(); articles2.addAll(articles); return articles2; } if (genre == Genre.MIXTE) { Query query = em.createQuery("SELECT a FROM Article a WHERE a.genre =:mon_genre"); query.setParameter("mon_genre", Genre.MIXTE); return query.getResultList(); } else { return em.createQuery("SELECT * FROM Article a").getResultList(); } }
From source file:com.plan.proyecto.repositorios.DaoCuentaImpl.java
@Override public List<Cuenta> findDeQuienSoyAmigoByCuenta(Cuenta cuenta) { Query query = em.createNamedQuery("Cuenta.findDeQuienSoyAmigoByCuenta"); query.setParameter("idorigen", cuenta.getId()); return query.getResultList(); }