Example usage for javax.persistence TypedQuery getResultList

List of usage examples for javax.persistence TypedQuery getResultList

Introduction

In this page you can find the example usage for javax.persistence TypedQuery getResultList.

Prototype

List<X> getResultList();

Source Link

Document

Execute a SELECT query and return the query results as a typed List.

Usage

From source file:org.mitre.openid.connect.repository.impl.JpaWhitelistedSiteRepository.java

@Override
@Transactional(value = "defaultTransactionManager")
public Collection<WhitelistedSite> getAll() {
    TypedQuery<WhitelistedSite> query = manager.createNamedQuery(WhitelistedSite.QUERY_ALL,
            WhitelistedSite.class);
    return query.getResultList();
}

From source file:rzd.vivc.documentexamination.repository.UserRepositoryImpl.java

@Override
///TODO   Typed query
public User findWithDependencies(Long userID) {
    TypedQuery createQuery = em.createQuery("SELECT u FROM User u LEFT JOIN FETCH u.department  WHERE u.id=:id",
            User.class);
    createQuery.setParameter("id", userID);
    return (User) createQuery.getResultList().get(0);
}

From source file:com.github.fharms.camel.route.CamelEntityManagerBean.java

public void findAllDogs(Exchange exchange) {
    TypedQuery<Dog> dogQuery = em2.createQuery("select d from Dog d", Dog.class);
    exchange.getIn().setBody(dogQuery.getResultList());
}

From source file:com.pingdu.dao.licenseDao.LicType_entTypeDao.java

public List<Integer> getLicenceTypeListByEntTypeCode(int entTypeCode) {
    String jpql = "select l.licTypeCode from LicType_entType l where l.entTypeCode=:entTypeCode";
    TypedQuery<Integer> query = em().createQuery(jpql, Integer.class);
    //query.setHint(QueryHints.RESULT_TYPE, ResultType.Map);
    query.setParameter("entTypeCode", entTypeCode);
    return query.getResultList();

}

From source file:com.devicehive.dao.rdbms.DeviceDaoRdbmsImpl.java

@Override
public long getAllowedDeviceCount(HivePrincipal principal, List<String> guids) {
    final CriteriaBuilder cb = criteriaBuilder();
    final CriteriaQuery<Device> criteria = cb.createQuery(Device.class);
    final Root<Device> from = criteria.from(Device.class);
    final Predicate[] predicates = CriteriaHelper.deviceListPredicates(cb, from, guids,
            Optional.ofNullable(principal));
    criteria.where(predicates);/* w  w w. java  2  s  .com*/
    final TypedQuery<Device> query = createQuery(criteria);
    return query.getResultList().size();
}

From source file:com.hartveld.commons.db.DAOBase.java

@Override
public List<T> retrieveAll() {
    LOG.trace("retrieveAll:");

    final TypedQuery<T> query = em.createQuery("from " + entityName, entityClass);

    return query.getResultList();
}

From source file:org.mitre.uma.repository.impl.JpaPermissionRepository.java

@Override
public Collection<PermissionTicket> getAll() {
    TypedQuery<PermissionTicket> query = em.createNamedQuery(PermissionTicket.QUERY_ALL,
            PermissionTicket.class);
    return query.getResultList();
}

From source file:com.costrategix.user.repository.JpaUserDao.java

public List<User> getAllList(int recordsPerPage, int pageNumber) {
    TypedQuery<User> query = em.createQuery("SELECT u FROM User u", User.class);
    query.setFirstResult(pageNumber * recordsPerPage);
    query.setMaxResults(recordsPerPage);
    return query.getResultList();
}

From source file:com.ewcms.content.particular.dao.FrontEmployeBasicDAO.java

public List<EmployeBasic> findEmployeBasicBySector(Long organId) {
    String hql = "From EmployeBasic As p where p.organ.id=:organId and p.release=true Order By p.published desc ";
    TypedQuery<EmployeBasic> query = this.getEntityManager().createQuery(hql, EmployeBasic.class);
    query.setParameter("organId", Integer.valueOf(organId.toString()));
    return query.getResultList();
}

From source file:br.eti.danielcamargo.backend.common.core.business.UsuarioService.java

public Usuario get(Long id) {
    TypedQuery<Usuario> query = em.createNamedQuery(Usuario.GET_USUARIO_BY_ID, Usuario.class);
    query.setParameter("id", id);
    List<Usuario> result = query.getResultList();
    return result.isEmpty() ? null : result.get(0);
}