List of usage examples for javax.persistence TypedQuery getResultList
List<X> getResultList();
From source file:com.pingdu.dao.licenseDao.LicenseDao.java
public List<License> getLicenseList(int page, int rows) { int head = (page - 1) * rows; String jpql = "select l from License l where 1=1 "; TypedQuery<License> query = em().createQuery(jpql, License.class); // query.setHint(QueryHints.RESULT_TYPE, ResultType.Map); query.setFirstResult(head);//from ww w . j a v a 2 s. c o m query.setMaxResults(rows); List<License> list = query.getResultList(); return list; }
From source file:br.ufrgs.inf.dsmoura.repository.model.dao.TypesDAO.java
public List<RelatedAssetTypeDTO> getRelatedAssetTypeDTOList() { TypedQuery<RelatedAssetTypeDTO> query = createEntityManager() .createQuery("SELECT t FROM RelatedAssetTypeDTO t", RelatedAssetTypeDTO.class); return query.getResultList(); }
From source file:it.volaconnoi.bean.RouteManagerBean.java
/** * Seleziona la tratta a minor prezzo che parte da un aeroporto * @return //ww w.j a va2 s .c o m */ @Override public Map<String, Float> getCityAirportByLowestRate() { TypedQuery<Object[]> query = em.createQuery( "SELECT r.airport_city_source.name, MIN(r.price) FROM Route r GROUP BY r.airport_city_source.name", Object[].class); List<Object[]> list = query.getResultList(); Map<String, Float> resultMap = new HashMap<>(list.size()); for (Object[] result : list) { resultMap.put((String) result[0], (Float) result[1]); } return resultMap; }
From source file:com.devicehive.dao.rdbms.NetworkDaoRdbmsImpl.java
@Override public List<NetworkVO> list(String name, String namePattern, String sortField, boolean sortOrderAsc, Integer take, Integer skip, Optional<HivePrincipal> principal) { CriteriaBuilder cb = criteriaBuilder(); CriteriaQuery<Network> criteria = cb.createQuery(Network.class); Root<Network> from = criteria.from(Network.class); Predicate[] nameAndPrincipalPredicates = CriteriaHelper.networkListPredicates(cb, from, ofNullable(name), ofNullable(namePattern), principal); criteria.where(nameAndPrincipalPredicates); CriteriaHelper.order(cb, criteria, from, ofNullable(sortField), sortOrderAsc); TypedQuery<Network> query = createQuery(criteria); cacheQuery(query, of(CacheConfig.refresh())); ofNullable(take).ifPresent(query::setMaxResults); ofNullable(skip).ifPresent(query::setFirstResult); List<Network> result = query.getResultList(); Stream<NetworkVO> objectStream = result.stream().map(Network::convertNetwork); return objectStream.collect(Collectors.toList()); }
From source file:com.music.dao.Dao.java
public <T> List<T> getByIds(Class<T> clazz, Collection<Long> ids) { if (ids.isEmpty()) { return Collections.emptyList(); }/*from w w w . j ava 2 s .c o m*/ TypedQuery<T> query = getEntityManager().createQuery("SELECT piece FROM Piece piece WHERE id IN (:ids)", clazz); query.setParameter("ids", ids); return query.getResultList(); }
From source file:br.ufrgs.inf.dsmoura.repository.model.dao.TypesDAO.java
public List<UserInterfaceTypeDTO> getUserInterfaceTypeDTOList() { TypedQuery<UserInterfaceTypeDTO> query = createEntityManager() .createQuery("SELECT t FROM UserInterfaceTypeDTO t", UserInterfaceTypeDTO.class); return query.getResultList(); }
From source file:com.deltastar.task7.core.repository.api.impl.CustomerRepositoryImpl.java
@Override public List<Customer> findCustomerByUserNameOrFirstNameOrLastName(String userName, String firstName, String lastName) {// ww w .java2 s . c om TypedQuery<Customer> query = entityManager.createNamedQuery("findCustomerByKeyWords", Customer.class); query.setParameter("p_userName", "%" + userName + "%"); query.setParameter("p_firstName", "%" + firstName + "%"); query.setParameter("p_lastName", "%" + lastName + "%"); return query.getResultList(); }
From source file:csns.model.core.dao.jpa.FileDaoImpl.java
@Override @PreAuthorize("authenticated and (#parent == null or #owner.id == principal.id)") public List<File> getFiles(User owner, File parent, String name, boolean isFolder) { String query = "from File where owner = :owner and name = :name " + "and folder = :isFolder and deleted = false and "; query += parent != null ? "parent = :parent" : "parent is null"; TypedQuery<File> typedQuery = entityManager.createQuery(query, File.class).setParameter("owner", owner) .setParameter("name", name).setParameter("isFolder", isFolder); if (parent != null) typedQuery.setParameter("parent", parent); return typedQuery.getResultList(); }
From source file:com.devicehive.dao.rdbms.UserDaoRdbmsImpl.java
@Override public List<UserVO> list(String login, String loginPattern, Integer role, Integer status, String sortField, Boolean sortOrderAsc, Integer take, Integer skip) { CriteriaBuilder cb = criteriaBuilder(); CriteriaQuery<User> cq = cb.createQuery(User.class); Root<User> from = cq.from(User.class); Predicate[] predicates = CriteriaHelper.userListPredicates(cb, from, ofNullable(login), ofNullable(loginPattern), ofNullable(role), ofNullable(status)); cq.where(predicates);//w w w. jav a 2 s. c om CriteriaHelper.order(cb, cq, from, ofNullable(sortField), Boolean.TRUE.equals(sortOrderAsc)); TypedQuery<User> query = createQuery(cq); cacheQuery(query, of(CacheConfig.refresh())); ofNullable(take).ifPresent(query::setMaxResults); ofNullable(skip).ifPresent(query::setFirstResult); return query.getResultList().stream().map(User::convertToVo).collect(Collectors.toList()); }
From source file:org.openmeetings.app.data.user.dao.UsersDaoImpl.java
public List<Users> getAllUsers() { try {/*from w w w .j a va 2 s . c o m*/ // get all non-deleted users CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Users> cq = cb.createQuery(Users.class); Root<Users> c = cq.from(Users.class); Predicate condition = cb.equal(c.get("deleted"), "false"); cq.where(condition); TypedQuery<Users> q = em.createQuery(cq); List<Users> ll = q.getResultList(); return ll; } catch (Exception ex2) { log.error("[getAllUsers] ", ex2); } return null; }