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.ilkgunel.hastaneotomasyonu.facade.AbstractFacade.java

@Transactional
public List<T> findListByNamedQuery(String namedQuery) throws Exception {
    Query q = getEntityManager().createNamedQuery(namedQuery);
    return q.getResultList();
}

From source file:myjpa.guest.model.Guests.java

private List<Guest> findAllNativeQuery() {
    String sql = "SELECT * FROM guest";
    Query nativeQuery = em.createNativeQuery(sql, Guest.class);

    return nativeQuery.getResultList();
}

From source file:cz.fi.muni.pa036.airticketbooking.dao.impl.CityDaoImpl.java

@Override
public List<City> getAll() {
    try {//from w  w w.  j  av a 2  s.  co m
        Query q = em.createQuery("FROM City");
        List<City> objectTemp = q.getResultList();

        return Collections.unmodifiableList(objectTemp);
    } catch (PersistenceException | IllegalArgumentException ex) {
        throw new DataAccessException(ex.getMessage(), ex) {
        };
    }
}

From source file:br.pucminas.ri.jsearch.querylog.LogController.java

synchronized public List<Log> getLogsByIp(String ip) {
    createConnection();//from   www  .j  a  v  a2  s.  c o  m
    String queryString = String.format("SELECT l FROM Log l WHERE l.ip = '%s'", ip);
    Query query = em.createQuery(queryString);
    query.getResultList();
    List<Log> result = query.getResultList();
    closeConnection();
    return result;
}

From source file:com.blogspot.chicchiricco.persistence.dao.impl.TestEntityDAOImpl.java

@Override
public List<TestEntity> findAll() {
    Query query = entityManager.createQuery("SELECT e FROM TestEntity e");

    return query.getResultList();
}

From source file:com.healthcit.cacure.dao.UserManagerDao.java

@Transactional(readOnly = true)
@SuppressWarnings("unchecked")
public List<Role> getUserRoles(UserCredentials user) {
    String jpql = "select u.roles from UserCredentials u where u = :user";
    Query query = em.createQuery(jpql);
    query.setParameter("user", user);
    return query.getResultList();
}

From source file:dao.HelloDAOImpl.java

@Transactional(readOnly = true)
@Override/*  w  ww.  j a  va 2 s.com*/
public List<HelloEntity> findAll() {
    Query q = em.createQuery("SELECT h FROM HelloEntity h");
    return q.getResultList();
}

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

@Override
public List<BasicCustomer> getBasicCustomerList() {

    List<BasicCustomer> list = new ArrayList<BasicCustomer>();
    String qString = "select  new com.dhenton9000.birt." + "jpa.domain.BasicCustomer(c.customerName,"
            + "c.phone," + "c.addressLine1," + "c.addressLine2," + "c.city," + "c.stateName," + "c.country,"
            + "c.postalCode," + "c.customerNumber)" + " from  Customers c";

    Query q = entityManager.createQuery(qString);
    list = q.getResultList();

    return list;/*from   w w  w  .  j ava 2s . co m*/
}

From source file:com.mvcmusic.mvcmusicstore.models.GenreModel.java

/**
 *
 * @return List<Genre>//  w  w  w .j av  a 2 s .c  o  m
 */
public List<Genre> findAllGenres() {
    List<Genre> genreList = new ArrayList<Genre>();

    try {
        Query q = em.createNamedQuery("Genre.findAll");
        genreList = q.getResultList();
    } catch (Exception e) {
        System.out.println("ERROR::: " + e);
    }

    return genreList;
}

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

@Override
public List<PaymentEntity> findActive() {
    Query namedQuery = em.createNamedQuery("PaymentEntity.findActive");
    return (List<PaymentEntity>) namedQuery.getResultList();
}