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.cimpoint.mes.server.repositories.PartRepository.java

@SuppressWarnings("unchecked")
public Set<EPart> findParts(PartFilter filter) throws Exception {
    //TODO filter
    Query query = this.getEntityManager().createQuery("SELECT p FROM EPart p");
    return (Set<EPart>) query.getResultList();
}

From source file:org.messic.server.datamodel.jpaimpl.DAOJPAPlaylist.java

@Override
@Transactional//ww  w  .  j a v  a  2 s .  co m
public List<MDOPlaylist> getAllDLNA() {
    Query query = entityManager.createQuery("from MDOPlaylist as a where (a.owner.allowDLNA = true)");

    @SuppressWarnings("unchecked")
    List<MDOPlaylist> results = query.getResultList();
    return results;
}

From source file:com.brienwheeler.svc.usergroups.impl.UserGroupMemberDao.java

@Override
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
@SuppressWarnings("unchecked")
public List<UserGroupMember> findForGroup(UserGroup userGroup) {
    Query query = entityManager.createQuery("from UserGroupMember where userGroup = :userGroup");
    query.setParameter("userGroup", userGroup);
    return (List<UserGroupMember>) query.getResultList();
}

From source file:pdsanchez.mywebtools.model.dao.jpa.SubcategoryDAOJPAImpl.java

@Override
public Subcategory find(String name) {
    Subcategory sc = null;//from w w  w . j  a  va2s .  c  o m

    Query q = getEntityManager()
            .createQuery("select o from Subcategory o where lower(o.subcategoryName) = :name");
    q.setParameter("name", name.toLowerCase());
    List<Subcategory> list = q.getResultList();
    if (!list.isEmpty()) {
        sc = list.get(0);
    }

    return sc;
}

From source file:vente.service.ArticleServiceImpl.java

public List<Article> findByTypeArticle(TypeArticle typeArticle) {
    List<Article> articles = new ArrayList<>();
    if (typeArticle == TypeArticle.MIXTE) {
        TypeArticle enfant = TypeArticle.ENFANT;
        Query query = em.createQuery(
                "SELECT a FROM Article a EXCEPT SELECT a1 FROM Article a1 WHERE a1.typeArticle = :enfant");
        query.setParameter("enfant", enfant);
        articles = query.getResultList();

    } else {/*from   w  ww .j a  v a 2s.c  om*/
        Query query = em.createQuery("SELECT a FROM Article a WHERE a.typeArticle = :typeArticle");
        query.setParameter("typeArticle", typeArticle);
        articles = query.getResultList();
    }
    return articles;
}

From source file:com.dhenton9000.birt.persistence.dao.impl.EmployeesDaoImpl.java

@Override
public List<Orders> getOrdersForEmployee(Integer employeeId) {

    String qString = "select o " + " from Orders o " + " join  o.customer   cust " + " join  cust.employee   e "
            + " where e.employeeNumber = :id ";

    Query q = this.getEntityManager().createQuery(qString);
    q.setParameter("id", employeeId);
    List orders = q.getResultList();

    //   http://www.objectdb.com/java/jpa/query/jpql/select

    return orders;
}

From source file:DAO.MessagesDAOImpl.java

/**
 * NOT YET IMPLEMENTED/*from  www.  j  a v a 2 s . co  m*/
 *
 * @param auteurId
 * @return
 */
@Transactional(readOnly = true)
@Override
public List<MessagesEntity> findByAuteur(int auteurId) {
    Query q = em.createQuery("SELECT m FROM MessagesEntity m where m.emetteur.id = ?");
    q.setParameter(1, auteurId);
    return q.getResultList();
}

From source file:org.kuali.mobility.emergencyinfo.dao.EmergencyInfoDaoImpl.java

@SuppressWarnings("unchecked")
public List<EmergencyInfo> findAllEmergencyInfo() {
    Query query = entityManager.createQuery("select ei from MaintEmergencyInfo ei order by ei.order");
    try {//from   w w  w  .  ja v  a 2 s  .com
        return query.getResultList();
    } catch (NoResultException e) {
        return null;
    }
}

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

@SuppressWarnings("unchecked")
@Override// w ww  . j  av  a  2  s  .  co m
public Policy find(Rule rule) {
    Query query = entityManager.createQuery("SELECT r.policy FROM RuleEntity r WHERE r = :rule")
            .setParameter("rule", rule);

    List<Policy> optionalResult = query.getResultList();
    return optionalResult.size() > 0 ? optionalResult.get(0) : null;
}

From source file:org.zkforge.zktodo2.BasicDao.java

/**
 * Retrieves a non-paged query. Use with care, this method could potentially
 * instantiate large amounts of data.//from   w  ww .  ja  v a2  s.  co m
 */
@SuppressWarnings("unchecked")
public <T> List<T> find(String queryString, Object... params) {
    Query query = entityManager.createQuery(queryString);
    setParameters(query, params);
    return query.getResultList();
}