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:net.triptech.metahive.model.Definition.java

/**
 * Find definition entries.// w w  w . ja  v a  2s .co m
 *
 * @param filter the definition filter
 * @param firstResult the first result
 * @param maxResults the max results
 * @return the list
 */
public static List<Definition> findDefinitionEntries(final DefinitionFilter filter, final int firstResult,
        final int maxResults) {

    StringBuilder sql = new StringBuilder("SELECT d FROM Definition d JOIN d.category c");
    sql.append(buildWhere(filter));
    sql.append(" ORDER BY d.name ASC");

    TypedQuery<Definition> q = entityManager().createQuery(sql.toString(), Definition.class)
            .setFirstResult(firstResult).setMaxResults(maxResults);

    HashMap<String, String> variables = buildVariables(filter);
    for (String variable : variables.keySet()) {
        q.setParameter(variable, variables.get(variable));
    }

    return q.getResultList();
}

From source file:de.lava.marvin.whaosleaguepersistence.dao.impl.LinkDaoImpl.java

@Override
public List<Link> getAllLinks() {
    TypedQuery<Link> query = entityManager.createNamedQuery("allLinks", Link.class);
    return query.getResultList();
}

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

public List<Organ> findPublishSelectorAll() {
    String hql = "From Organ As p Order By p.id ";
    TypedQuery<Organ> query = this.getEntityManager().createQuery(hql, Organ.class);
    return query.getResultList();
}

From source file:model.dao.RoleDAOImpl.java

@Override
public <T> List<T> getAllRoles() {
    TypedQuery<T> query = em.createQuery("from Role", (Class<T>) Role.class);
    return query.getResultList();
}

From source file:de.lava.marvin.whaosleaguepersistence.dao.impl.MatchDaoImpl.java

@Override
public List<Match> getAllMatches() {
    TypedQuery<Match> query = entityManager.createNamedQuery("allMatches", Match.class);
    return query.getResultList();
}

From source file:de.lava.marvin.whaosleaguepersistence.dao.impl.LeagueDaoImpl.java

@Override
public List<League> getAllLeagues() {
    TypedQuery<League> query = entityManager.createNamedQuery("allLeagues", League.class);
    return query.getResultList();
}

From source file:com.costrategix.user.repository.JpaUserDao.java

public List<User> getAllList() {
    TypedQuery<User> query = em.createQuery("SELECT u FROM User u", User.class);
    return query.getResultList();
}

From source file:de.lava.marvin.whaosleaguepersistence.dao.impl.MatchDaoImpl.java

@Override
public List<Match> getAllRankedMatches() {
    TypedQuery<Match> query = entityManager.createNamedQuery("allRankedMatches", Match.class);
    return query.getResultList();
}

From source file:de.lava.marvin.whaosleaguepersistence.dao.impl.LeagueDaoImpl.java

@Override
public List<League> getAllRankedLeagues() {
    TypedQuery<League> query = entityManager.createNamedQuery("allRankedLeagues", League.class);
    return query.getResultList();
}

From source file:de.lava.marvin.whaosleaguepersistence.dao.impl.MatchDaoImpl.java

@Override
public List<Match> getAllUnrankedMatches() {
    TypedQuery<Match> query = entityManager.createNamedQuery("allUnrankedMatches", Match.class);
    return query.getResultList();
}