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:nc.noumea.mairie.organigramme.core.dao.PersistentManager.java

public List<T> findAllByPropertyOrderBy(Class<? extends T> classe, String property, Object value,
        String orderByProperty) {
    TypedQuery<T> q = constructTypedQueryByPropertyOrderBy(classe, property, value, orderByProperty);
    return q.getResultList();
}

From source file:bq.jpa.demo.version.service.VersionService.java

@Transactional
public void showResult() {
    TypedQuery<Employee> query = em.createQuery("SELECT e FROM jpa_version_employee e", Employee.class);
    List<Employee> results = query.getResultList();
    ResultViewer.showResult(results, "show all employees");
}

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

@Override
public List<Mensaje> findMensajeByCuenta(Cuenta cuenta) {

    if (cuenta == null) {
        return null;
    }/*from  www .  j av a2  s . c om*/

    TypedQuery<Mensaje> query = em.createNamedQuery("Mensaje.findMensajeByCuenta", Mensaje.class);
    query.setParameter("idValor", cuenta.getId());

    return query.getResultList();
}

From source file:bq.jpa.demo.version.service.VersionService.java

/**
 * modify related address will not change employee's version automatically
 */// w w w.  j a va2  s.  c o m
@Transactional
public void doUpdateAddress() {
    TypedQuery<Address> query = em.createQuery("SELECT a FROM jpa_version_address a", Address.class);
    List<Address> results = query.getResultList();
    for (int i = 0; i < results.size(); i++) {
        Address address = results.get(i);
        address.setState("MI");
        address.setCity("Lansing");
    }
}

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

public List<EmployeArticle> findEmployeArticleByCode(String code) {
    String hql = "From EmployeArticle As p where p.employeBasic.cardCode=:code and p.release=true Order By p.published desc ";
    TypedQuery<EmployeArticle> query = this.getEntityManager().createQuery(hql, EmployeArticle.class);
    query.setParameter("code", code);
    return query.getResultList();
}

From source file:bq.jpa.demo.version.service.VersionService.java

/**
 * can change version automatically//from  ww w.  j  a va2s.  c o m
 */
@Transactional
public void doUpdate() {
    TypedQuery<Employee> query = em.createQuery("SELECT e FROM jpa_version_employee e", Employee.class);
    List<Employee> results = query.getResultList();
    for (Employee e : results)
        e.setName("new_employee");
}

From source file:com.deltastar.task7.core.repository.api.impl.FundPriceHistoryViewRepositoryImpl.java

@Override
public List<FundPriceHistoryView> getFundPriceHistoryViewListById(int fundId) {

    TypedQuery<FundPriceHistoryView> query = entityManager.createNamedQuery("findFundPriceHistoryByFundId",
            FundPriceHistoryView.class);
    query.setParameter("p_fundId", fundId);
    return query.getResultList();

}

From source file:it.volaconnoi.bean.RouteManagerBean.java

@Override
public List<Route> getRoutesList() {
    TypedQuery<Route> query = em.createNamedQuery("Route.findAll", Route.class);

    return query.getResultList();
}

From source file:com.beto.test.securityinterceptor.model.dao.generic.AbstractDao.java

public List<T> getListWithNamedQuery(String query, String inParamName, List<?> inList) throws Exception {

    try {/*  ww w  . j  av  a 2s . co  m*/
        TypedQuery<T> tq = getEntityManager().createNamedQuery(query, entityClass);
        tq.setParameter(inParamName, inList);
        return tq.getResultList();
    } catch (NoResultException e) {
        LOGGER.debug("NO DATA FOUND...");
    }
    return null;
}

From source file:com.deltastar.task7.core.repository.api.impl.FundRepositoryImpl.java

@Override
public Fund getFundBySymbol(String symbol) {
    TypedQuery<Fund> query = entityManager.createNamedQuery("findFundBySymbol", Fund.class);
    query.setParameter("p_symbol", symbol);
    List<Fund> fundList = query.getResultList();
    return (fundList != null && !fundList.isEmpty()) ? fundList.get(0) : null;
}