List of usage examples for javax.persistence TypedQuery getResultList
List<X> getResultList();
From source file:de.lava.marvin.whaosleaguepersistence.dao.impl.LeagueDaoImpl.java
@Override public List<League> getAllUnrankedLeagues() { TypedQuery<League> query = entityManager.createNamedQuery("allUnrankedLeagues", League.class); return query.getResultList(); }
From source file:kievreclama.task.dao.impl.DepartmentDaoImpl.java
@Override @Transactional/*from w ww.jav a 2 s .com*/ public List<Department> byList(String namedQery) { Session session = sessionFactory.getCurrentSession(); TypedQuery<Department> typedQuery = session.createNamedQuery(namedQery, Department.class); return typedQuery.getResultList(); }
From source file:model.dao.UserDAOImpl.java
@SuppressWarnings("unchecked") @Override//w w w .j a v a 2 s .co m public <T> List<T> listUsers(Class<T> clazz) { TypedQuery<T> query = em.createQuery("from " + clazz.getName(), clazz); return query.getResultList(); }
From source file:cz.muni.fi.pa165.bookingmanager.managers.UserManager.java
@Override public List<User> findAll() { CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaQuery<User> query = criteriaBuilder.createQuery(User.class); Root<User> c = query.from(User.class); query.select(c);//w w w. ja v a2 s. c om TypedQuery<User> typedQuery = entityManager.createQuery(query); return typedQuery.getResultList(); //return em.createQuery("SELECT u FROM User u WHERE u.user = :user", User.class).setParameter("user", user).getResultList(); }
From source file:ext.msg.model.Message.java
public static Page<Message> queryMessageByRead(int page, int pageSize, String consumeOnly, Collection<?> msgTypes, boolean unReadFirst) { String countQL = " select count(m) from Message m where m.consumeOnly = :consumeOnly "; String contentQL = " from Message m where m.consumeOnly = :consumeOnly "; if (CollectionUtils.isNotEmpty(msgTypes)) { countQL += " and m.msgType in (:msgTypes) "; contentQL += " and m.msgType in (:msgTypes) "; }/* www. j a va 2s . c o m*/ if (unReadFirst) { contentQL += " order by isRead asc, m.id desc "; } else { contentQL += " order by m.id desc "; } TypedQuery<Long> countQuery = JPA.em().createQuery(countQL, Long.class).setParameter("consumeOnly", consumeOnly); TypedQuery<Message> contentQuery = JPA.em().createQuery(contentQL, Message.class) .setParameter("consumeOnly", consumeOnly); if (CollectionUtils.isNotEmpty(msgTypes)) { countQuery.setParameter("msgTypes", msgTypes); contentQuery.setParameter("msgTypes", msgTypes); } contentQuery.setFirstResult(page * pageSize).setMaxResults(pageSize); Long total = countQuery.getSingleResult(); List<Message> data = contentQuery.getResultList(); Page<Message> pageMsg = new Page<Message>(Constants.SUCESS, total, data); return pageMsg; }
From source file:br.com.sementesdoamanha.repository.Servidores.java
public List<Servidor> filtrados(ServidorFilter filtro) { //select, from, where, like... --> select(), from(), where() //JPQL: from Servidor //JPQL: select s from Servidor s where c.nome like = 'Joo%' and c.cpf = like '046.244.901-77' CriteriaBuilder builder = manager.getCriteriaBuilder(); CriteriaQuery<Servidor> criteriaQuery = builder.createQuery(Servidor.class); Root<Servidor> s = criteriaQuery.from(Servidor.class); criteriaQuery.select(s);//from w w w . ja va2 s . c o m List<Predicate> predicates = new ArrayList<>(); if (StringUtils.isNotBlank(filtro.getCpf())) { predicates.add(builder.equal(s.<String>get("cpf"), filtro.getCpf())); } if (StringUtils.isNotBlank(filtro.getNome())) { predicates .add(builder.like(builder.upper(s.<String>get("nome")), filtro.getNome().toUpperCase() + "%")); } criteriaQuery.where(predicates.toArray(new Predicate[0])); TypedQuery<Servidor> query = manager.createQuery(criteriaQuery); return query.getResultList(); }
From source file:fi.vm.kapa.identification.metadata.dao.MetadataDAO.java
public List<Metadata> getAllMetadata() { TypedQuery<Metadata> query = entityManager.createNamedQuery("Metadata.getAll", Metadata.class); return query.getResultList(); }
From source file:net.osgiliath.jpa.repository.impl.HelloJpaRepository.java
@Override public Collection<? extends HelloEntity> findByHelloObjectMessage(String message_p) { CriteriaBuilder cb = entityManager.getCriteriaBuilder(); CriteriaQuery<HelloEntity> cq = cb.createQuery(HelloEntity.class); Root<HelloEntity> helloObject = cq.from(HelloEntity.class); cq.select(helloObject);/* w w w . ja v a2s . c o m*/ Predicate where = cb.equal(helloObject.get("helloMessage"), message_p); cq.where(where); TypedQuery<HelloEntity> q = entityManager.createQuery(cq); List<HelloEntity> result = q.getResultList(); return result; }
From source file:org.broadleafcommerce.menu.dao.MenuDaoImpl.java
@Override public List<Menu> readAllMenus() { TypedQuery<Menu> q = new TypedQueryBuilder<Menu>(Menu.class, "m").toQuery(em); return q.getResultList(); }
From source file:com.ewcms.content.particular.dao.FrontEmployeBasicDAO.java
public List<EmployeBasic> findEmployeBasicAll(Integer number) { if (number == null) { String hql = "From EmployeBasic As e where e.release=true Order By e.published desc"; TypedQuery<EmployeBasic> query = this.getEntityManager().createQuery(hql, EmployeBasic.class); return query.getResultList(); } else {/*from w w w. j a va 2 s. c o m*/ String hql = "From EmployeBasic As e where e.release=true Order By e.published desc limit " + number; TypedQuery<EmployeBasic> query = this.getEntityManager().createQuery(hql, EmployeBasic.class); return query.getResultList(); } }