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:org.syncope.core.persistence.dao.impl.TaskExecDAOImpl.java

@Override
public <T extends Task> List<TaskExec> findAll(Class<T> reference) {
    StringBuilder queryString = new StringBuilder("SELECT e FROM ").append(TaskExec.class.getSimpleName())
            .append(" e WHERE e.task IN (").append("SELECT t FROM ").append(reference.getSimpleName())
            .append(" t");
    if (SchedTask.class.equals(reference)) {
        queryString.append(" WHERE t.id NOT IN (SELECT t.id FROM ").append(SyncTask.class.getSimpleName())
                .append(" t) ");
    }//from ww w  .  jav a2 s.c om
    queryString.append(')');

    Query query = entityManager.createQuery(queryString.toString());
    return query.getResultList();
}

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

@Override
public List<EventRegister> getEventRegisterByUserId(int id) {
    Query query = this.entityManager.createQuery("SELECT er from EventRegister er where er.user.id=:id");
    query.setParameter("id", id);
    return query.getResultList();
}

From source file:eu.domibus.common.dao.PartyDao.java

public Collection<Identifier> findPartyIdentifiersByEndpoint(String endpoint) {
    final Query query = this.em.createNamedQuery("Party.findPartyIdentifiersByEndpoint");
    query.setParameter("ENDPOINT", endpoint);

    return query.getResultList();
}

From source file:Message.java

  public void messageCreateAndList() {
  em.persist(new Message("Hello Persistence!"));
  Query q = em.createQuery("select m from Message m");

  for (Message m : (List<Message>) q.getResultList()) {
      System.out.println(m.getMessage()
          + " (created on: " + m.getCreated() + ")"); 
  }/*  w  w w .  j a va2  s  .c  o m*/
}

From source file:com.healthcit.cacure.dao.BaseJpaDao.java

@SuppressWarnings("unchecked")
public List<T> list() {
    Query query = em.createQuery("FROM " + persistentClass.getSimpleName() + " c");
    List<T> results = query.getResultList();
    return results;
}

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

@Override
public List<Role> findAll() {
    Query query = getEntityManager().createQuery("SELECT r FROM Role r ORDER BY r.name");
    setReadOnly(query);//from  w w  w .j  a va2 s.  com

    return query.getResultList();
}

From source file:com.ovalsearch.dao.impl.ApplicationsDaoImpl.java

@SuppressWarnings("unchecked")
@Override//from  w  w w .  j av a2  s  . c  o  m
public List<Applications> getAllApplicationsByQuery() {
    String queryString = CacheManager.getInstance().getCache(PropertyMapCache.class)
            .getPropertyString(Property.ALL_APPLICATIONS_QUERY);
    Query query = entityDao.getEntityManager().createQuery(queryString);
    List<Applications> resultSet = (List<Applications>) query.getResultList();
    return resultSet;
}

From source file:com.june.app.site.repository.jpa.VideoRepositoryImpl.java

@SuppressWarnings("unchecked")
@Override//  w  ww .  ja va2  s . co  m
public Collection<Video> videoMainList() {

    String queryString = "SELECT video FROM Video video WHERE video.useYn ='Y' ORDER BY video.regiDate desc";
    Query query = this.em.createQuery(queryString);
    query.setMaxResults(8);
    return query.getResultList();
}

From source file:com.dhenton9000.birt.jpa.service.impl.EmployeesServiceImpl.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 = entityManager.createQuery(qString);
    q.setParameter("id", employeeId);
    List orders = q.getResultList();
    return orders;
}

From source file:com.pet.demo.repository.jpa.JpaVisitRepositoryImpl.java

@SuppressWarnings("unchecked")
public List<Visit> findByPetId(Integer petId) {
    Query query = this.em.createQuery("SELECT visit FROM Visit v where v.pets.id= :id");
    query.setParameter("id", petId);
    return query.getResultList();
}