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:nc.noumea.mairie.appock.dao.impl.AppUserDaoImpl.java

@SuppressWarnings("unchecked")
@Override/*from w  w  w.ja  v  a  2  s.  com*/
public List<AppUser> findAllWithRole(Role role) {
    String orderBy = " ORDER BY u.actif desc, u.nom, u.prenom asc";
    String requeteJpa = "SELECT u FROM AppUser u INNER JOIN u.listeRole r " //
            + " WHERE r=:role " //
            + orderBy;
    Query query = persistentManager.getEntityManager().createQuery(requeteJpa);
    query.setParameter("role", role);
    return query.getResultList();
}

From source file:cz.muni.expense.data.RuleRepository.java

public List<Rule> findRulesByUserId(Long userId) {
    Query query = em.createQuery("SELECT r FROM Rule r " + "WHERE r.user.id = :userId");
    query.setParameter("userId", userId);
    return query.getResultList();
}

From source file:modelo.dao.GestionProductosImpl.java

@Override
public List<Producto> obtenerProductos(int user) {
    Query q = em.createNamedQuery("Producto.findByUser");
    q.setParameter(1, user);//w  ww. ja va 2s.  com

    return q.getResultList();
}

From source file:org.kuali.mobility.configparams.dao.ConfigParamDaoImpl.java

@SuppressWarnings("unchecked")
public List<ConfigParam> findAllConfigParam() {
    Query query = entityManager.createQuery("select cp from ConfigParam cp order by cp.name");
    return query.getResultList();
}

From source file:org.simbasecurity.core.domain.repository.GroupDatabaseRepository.java

@Override
public Collection<Group> find(User user) {
    ArrayList<Group> result = new ArrayList<Group>();
    Query query = entityManager.createQuery("SELECT g FROM GroupEntity g ");
    for (Group group : (List<Group>) query.getResultList()) {
        if (group.getUsers().contains(user)) {
            result.add(group);/*from   ww w. j ava 2  s  .  com*/
        }
    }
    return result;
    //        TODO: use implementation below when hibernate bug is fixed
    //        Query query = entityManager.createQuery(
    //                "SELECT g FROM GroupEntity g " +
    //                "WHERE :user in g.users")
    //                .setParameter("user", user);
    //        return query.getResultList();
}

From source file:at.irian.demo.jsfatwork.repository.jpa.JpaVotingRepository.java

@Override
public List<Vote> loadVotes(User user) {
    Query query = this.entityManager.createNamedQuery(FIND_ALL_VOTES_OF_USER);
    query.setParameter(PARAMETER_USER, user);

    return query.getResultList();
}

From source file:cz.muni.fi.pa165.deliveryservice.dao.jpa.JPACourierDAO.java

@Override
public List<Courier> getAllCouriers(boolean include_deleted) {
    String q = "";
    if (!include_deleted) {
        q = " WHERE c.active = true";
    }/*from  ww  w  .j  a v a  2s . c  o m*/
    Query query = em.createQuery("SELECT c FROM Courier c" + q);
    return query.getResultList();
}

From source file:org.thingsplode.TestBaseWithRepos.java

/**
 * A very resource efficient counter method (it will not return all the
 * objects from the database and count them, but execute <b>select count(*)
 * from " + tableName</b> and return the result.
 *
 * @param tableName the table for which you want to count the elements
 * @return the number of rows in that table.
 */// w  w w. jav  a  2s.c  o m
protected Integer getCount(String tableName) {
    Query q = entityManager.createNativeQuery("select count(*) from " + tableName);
    return ((BigInteger) q.getResultList().get(0)).intValue();
}

From source file:com.sun.socialsite.business.impl.JPAContextRuleManagerImpl.java

/**
 * Note: using SuppressWarnings annotation because the JPA API is
 * not genericized.//from   w w w  .  j a  v a  2  s . c  o m
 */
@SuppressWarnings(value = "unchecked")
public List<ContextRule> getRules() throws SocialSiteException {
    Query query = strategy.getNamedQuery("ContextRule.getAll");
    return (List<ContextRule>) query.getResultList();
}

From source file:modelo.DaoTiposActividadesImpl.java

@Override
public List<TipoActividad> mostrarActividades() {
    String jpql = "select act from Actividad act";

    Query q = em.createQuery(jpql);
    List<TipoActividad> actividades = (List<TipoActividad>) q.getResultList();
    em.close();//from w w  w .ja  va2  s.  c  o  m
    return actividades;
}