Example usage for javax.persistence Query getResultList

List of usage examples for javax.persistence Query getResultList

Introduction

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

Prototype

List getResultList();

Source Link

Document

Execute a SELECT query and return the query results as an untyped List.

Usage

From source file:com.gymadmin.persistence.dao.impl.PaymentDaoImpl.java

@Override
public List<PaymentEntity> findActiveByCustomer(Integer customerId) {
    Query namedQuery = em.createNamedQuery("PaymentEntity.findActiveByCustomer");
    namedQuery.setParameter("customerId", customerId);
    return (List<PaymentEntity>) namedQuery.getResultList();
}

From source file:com.nandhootoo.services.StatusServiceImpl.java

public List getStatusesWithCriteria(String criteria) {
    try {//from   ww  w .  j av  a2 s . com
        Query aQuery = entityManager.createQuery("select status from Status as status " + criteria);
        return aQuery.getResultList();
    } catch (Exception sqlex) {
        System.out.println("SQL Exception: " + sqlex.getMessage());
        return null;
    }
}

From source file:net.chrissearle.flickrvote.dao.JpaPhotographyDao.java

/**
 * Method all returns all photographers//from  ww w. ja  va2s  . c  o  m
 *
 * @return List<Photographer>
 */
@SuppressWarnings("unchecked")
public List<Photographer> all() {
    Query query = entityManager.createQuery("SELECT p FROM Photographer p");

    return (List<Photographer>) query.getResultList();
}

From source file:com.brienwheeler.svc.users.impl.UserRoleDao.java

@Override
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
@SuppressWarnings("unchecked")
public List<String> findByUserAsStrings(User user) {
    Query query = entityManager.createQuery("select role from UserRole where user = :user");
    query.setParameter("user", user);
    return (List<String>) query.getResultList();
}

From source file:com.dhenton9000.birt.jpa.service.impl.EmployeesServiceImpl.java

@Override
public List<SalesReport> getSalesData() {
    String qString = "select  new com.dhenton9000.birt." + "jpa.domain.SalesReport(e.firstName, e.lastName,"
            + "SUM(details.priceEach),e.employeeNumber)" + " from  Orders o" + " join  o.orderDetails details"
            + " join  o.customer   cust " + " join  cust.employee   e " + " GROUP BY e.employeeNumber"
            + " ORDER BY e.lastName, e.firstName";

    Query q = entityManager.createQuery(qString);
    //q.setParameter("id", employeeId);
    List<SalesReport> salesData = q.getResultList();

    //   http://www.objectdb.com/java/jpa/query/jpql/select

    return salesData;
}

From source file:gumga.framework.application.GumgaCrudAndQueryNotOnlyTypedRepositoryImpl.java

@Override
public List getResultList(String hql, Map<String, Object> param, int maxResult) {
    javax.persistence.Query query = entityManager.createQuery(hql);
    query.setMaxResults(maxResult);/*w w  w. j  av  a 2  s  .  co m*/
    addParam(query, param);
    return query.getResultList();
}

From source file:modelo.dao.GestionHistoricoImpl.java

@Override
public List<Historico> obtenerHistorico(String referencia, int usuario) {
    Query q = em.createNamedQuery("Historico.findLastDateByRef");
    q.setParameter(1, referencia);// w ww.j a  va 2s.co m
    q.setParameter(2, usuario);
    return q.getResultList();
}

From source file:org.messic.server.datamodel.jpaimpl.DAOJPAMessicSettings.java

@Override
@Transactional//from w ww  .  j av  a2 s . c om
public MDOMessicSettings getSettings() {
    Query query = entityManager.createQuery("from MDOMessicSettings");

    @SuppressWarnings("unchecked")
    List<MDOMessicSettings> results = query.getResultList();
    if (results == null || results.size() == 0) {
        return createBasicSettings();
    } else {
        return results.get(0);
    }
}

From source file:org.waastad.enumjparest.service.RatingServiceIT.java

@Test
public void test_04_correct_insert_webclient() throws Exception {
    System.out.println("test_04_correct_insert_webclient");
    List<Object> providers = new ArrayList<>();
    providers.add(new JacksonJaxbJsonProvider());
    WebClient client = WebClient.create("http://127.0.0.1:4204/TomeeEnumRest/rest", providers);
    ClientConfiguration config = WebClient.getConfig(client);
    config.getOutInterceptors().add(new LoggingOutInterceptor());
    config.getInInterceptors().add(new LoggingInInterceptor());
    Movie movie = new Movie("flaaklypa", Rating.G);
    client.accept(MediaType.APPLICATION_JSON);
    client.type(MediaType.APPLICATION_JSON);
    Collection<? extends Movie> postObjectGetCollection = client.postObjectGetCollection(movie, Movie.class);

    Query q = em.createQuery("SELECT t FROM Movie t");
    List resultList = q.getResultList();
    Assert.assertEquals(2, resultList.size());
    q = em.createQuery("SELECT t FROM Movie t WHERE t.rating=:rating").setParameter("rating", Rating.G);
    List resultList1 = q.getResultList();
    Assert.assertEquals(1, resultList1.size());
}

From source file:ca.travelagency.persistence.DaoSupportImpl.java

@SuppressWarnings("unchecked")
@Override//from  w w  w.  ja  va 2  s. co m
public List<T> find(DaoCriteria daoCriteria) {
    Query query = QuerySQL.find(daoCriteria.getCriteria(), entityManager).makeQuery();
    return (List<T>) query.getResultList();
}