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.impetus.client.oraclenosql.OracleNoSQLTestBase.java

protected List executeSelectQuery(String jpaQuery) {
    Query query = em.createQuery(jpaQuery);
    return query.getResultList();
}

From source file:com.expressui.sample.dao.LeadSourceDao.java

@Override
public List<LeadSource> findAll() {
    Query query = getEntityManager().createQuery("SELECT l FROM LeadSource l ORDER BY l.sortOrder");
    setReadOnly(query);/*  w  ww .  java 2s. co m*/

    return query.getResultList();
}

From source file:com.expressui.sample.dao.SalesStageDao.java

@Override
public List<SalesStage> findAll() {
    Query query = getEntityManager().createQuery("SELECT s FROM SalesStage s ORDER BY s.sortOrder");
    setReadOnly(query);/*from  ww w .  ja  va 2 s.c  o m*/

    return query.getResultList();
}

From source file:com.tamnd2.basicwebapp.core.repositories.jpa.JpaAccountRepo.java

@Override
public Account findAccountByName(String name) {
    Query query = em.createQuery("SELECT a FROM Account a WHERE a.name=?1");
    query.setParameter(1, name);//www.ja va 2s  .  c  om
    List<Account> accounts = query.getResultList();
    if (accounts.isEmpty()) {
        return null;
    } else {
        return accounts.get(0);
    }
}

From source file:com.tamnd2.basicwebapp.core.repositories.jpa.JpaBlogRepo.java

@Override
public Blog findBlogByTitle(String title) {
    Query query = em.createQuery("SELECT b from Blog b where b.title=?1");
    query.setParameter(1, title);//from  w w  w .  j a va2s .  co  m
    List<Blog> blogs = query.getResultList();
    if (blogs.isEmpty()) {
        return null;
    } else {
        return blogs.get(0);
    }
}

From source file:com.expressui.sample.dao.IndustryDao.java

@Override
public List<Industry> findAll() {
    Query query = getEntityManager().createQuery("SELECT i FROM Industry i ORDER BY i.displayName");
    setReadOnly(query);/*from  w ww  .j av  a 2 s  . c  om*/

    return query.getResultList();
}

From source file:com.plan.proyecto.repositorios.DaoCuentaImpl.java

@Override
public void limpiezaCuentas() {
    Query query = em.createNamedQuery("Cuenta.findAll");
    List<Cuenta> cuentas = query.getResultList();

    for (Cuenta cuenta : cuentas) {
        //            eliminar(cuenta);
        em.remove(cuenta);//from w w  w. ja v a2 s .  c o m
    }
}

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

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

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

From source file:cz.muni.pa165.carparkapp.DAOImpl.CarDAOImpl.java

@Override
public Car findCarById(int id) {
    Validate.isTrue(id > 0, "Car's ID cannot be null!");

    Query query = em.createQuery("select c from Car c " + "where c.id = ?1").setParameter(1, id);
    if (query.getResultList() == null) {
        throw new IllegalArgumentException("Error in query");
    }//from w  w  w. ja v a 2 s .c om
    if (query.getResultList().size() != 1) {
        throw new IllegalArgumentException("No car found");
    }
    return ((List<Car>) query.getResultList()).get(0);
}

From source file:edu.mum.dao.impl.AuthorityDaoImpl.java

@Override
public Authority findOneByName(String name) {
    Query query = entityManager.createQuery("from Authority e where e.name = :name");
    query.setParameter("name", name);
    List<Authority> authority = query.getResultList();
    if (authority.isEmpty()) {
        return null;
    } else {/*from   ww w  .j a  v  a2s  .c  o m*/
        return authority.get(0);
    }

}