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:com.enioka.jqm.tools.NoApiPayloadTest.java

@Test
public void testProvidedApi() throws Exception {
    CreationTools.createJobDef(null, true, "App", null, "jqm-tests/jqm-test-providedapi/target/test.jar",
            TestHelpers.qVip, 42, "MarsuApplication", null, "Franquin", "ModuleMachin", "other", "other", true,
            em);//from ww  w . ja  v a  2s  .c  o  m

    // Create an empty lib directory just to be sure no dependencies will be resolved.
    FileUtils.forceMkdir(new File("../jqm-tests/jqm-test-providedapi/target/lib"));

    JobRequest j = new JobRequest("MarsuApplication", "TestUser");
    JqmClientFactory.getClient().enqueue(j);

    addAndStartEngine();
    TestHelpers.waitFor(1, 10000, em);

    TypedQuery<History> query = em.createQuery("SELECT j FROM History j", History.class);
    ArrayList<History> res = (ArrayList<History>) query.getResultList();

    Assert.assertEquals(1, res.size());
    Assert.assertEquals(State.ENDED, res.get(0).getState());
}

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

@Override
public List<Transition> getPendingTransitionList() {
    TypedQuery<Transition> query = entityManager.createNamedQuery("findTransitionByStatus", Transition.class);
    query.setParameter("p_status", CCConstants.TRAN_STATUS_PENDING);
    return query.getResultList();
}

From source file:com.siriusit.spezg.multilib.storage.jpa.JpaMessageRepository.java

@Override
public List<? extends Message> findMessagesByReceiver(Person receiver) {
    TypedQuery<MessageDomainObject> query = entityManager.createNamedQuery("findMessageByReceiver",
            MessageDomainObject.class);
    query.setParameter("receiver", receiver);
    return query.getResultList();
}

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

@Override
public List<Player> getAllPlayers() {
    TypedQuery<Player> query = entityManager.createNamedQuery("allPlayers", Player.class);
    return query.getResultList();
}

From source file:org.mitre.openid.connect.repository.impl.JpaUserInfoRepository.java

/**
 * Get a single UserInfo object by its email address
 *///  w w w .  j  a va 2 s  .  co  m
@Override
public UserInfo getByEmailAddress(String email) {
    TypedQuery<DefaultUserInfo> query = manager.createNamedQuery(DefaultUserInfo.QUERY_BY_EMAIL,
            DefaultUserInfo.class);
    query.setParameter(DefaultUserInfo.PARAM_EMAIL, email);

    return getSingleResult(query.getResultList());
}

From source file:org.openmeetings.app.data.basic.dao.OmTimeZoneDaoImpl.java

public OmTimeZone getOmTimeZoneByIcal(String ical) {
    try {/*w w  w  .  ja  va  2  s.  c  o  m*/
        String hql = "select sl from OmTimeZone as sl " + "WHERE sl.ical LIKE :ical";
        TypedQuery<OmTimeZone> query = em.createQuery(hql, OmTimeZone.class);
        query.setParameter("ical", ical);
        List<OmTimeZone> sList = query.getResultList();

        if (sList.size() > 0) {
            return sList.get(0);
        }

    } catch (Exception ex2) {
        log.error("[getOmTimeZoneByIcal]: ", ex2);
    }
    return null;
}

From source file:org.verinice.persistence.CnaTreeElementDaoImpl.java

@Override
public List<CnaTreeElement> findByScopeKeyValue(Integer scopeId, String key, String value, Integer size,
        Integer firstResult) {/*from  ww w  . j  ava  2s  .c om*/
    enableAccessControlFilters();

    TypedQuery<CnaTreeElement> query = createQueryForScopeKeyValue(scopeId, key, value);
    configureResultSize(query, size, firstResult);

    List<CnaTreeElement> dbElements = query.getResultList();
    logger.debug("Result size: " + dbElements.size());

    return dbElements;
}

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

@Override
public List<TransitionView> getPendingTransitionList() {
    TypedQuery<TransitionView> query = entityManager.createNamedQuery("findTransitionViewByStatus",
            TransitionView.class);
    query.setParameter("p_status", CCConstants.TRAN_STATUS_PENDING);
    return query.getResultList();
}

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

@Override
public Contenido findMensajeByComentario(Contenido comentario) {

    if (comentario == null) {
        return null;
    }/*from   w w w .j a v  a  2s.c om*/

    TypedQuery<Contenido> query = em.createNamedQuery("Contenido.findMensajeByComentario", Contenido.class);
    query.setParameter("valor", comentario);
    List<Contenido> listaTemp = query.getResultList();

    Contenido retorno;

    if (listaTemp.isEmpty()) {
        retorno = null;
    } else {
        retorno = listaTemp.get(0);
    }
    return retorno;
}

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

@Override
public List<Transition> getTransitionListByCustomerId(int customerId) {
    TypedQuery<Transition> query = entityManager.createNamedQuery("findTransitionByCustomerId",
            Transition.class);
    query.setParameter("p_customerId", customerId);

    return query.getResultList();
}