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.deltastar.task7.core.repository.api.impl.TransitionViewRepositoryImpl.java

@Override
public List<TransitionView> getTransitionListByCustomerId(int customerId) {
    TypedQuery<TransitionView> query = entityManager.createNamedQuery("findTransitionViewByCustomerId",
            TransitionView.class);
    query.setParameter("p_customerId", customerId);
    return query.getResultList();
}

From source file:com.greendot.db.jpa.core.AbstractSearchDao.java

@Transactional(readOnly = true)
public List<E> findAll() {

    try {/*from w w  w.  j  a va  2s  .  com*/
        final CriteriaQuery<E> query = getEntityManager().getCriteriaBuilder().createQuery(entityType);
        final Root<E> root = query.from(entityType);
        final CriteriaQuery<E> rootQuery = query.select(root);
        final TypedQuery<E> allQuery = getEntityManager().createQuery(rootQuery);
        stopWatchThread.get().start();
        final List<E> rows = allQuery.getResultList();
        stopWatchThread.get().stop();
        LOG.info("Located: [{} rows] during findAll({}) in [{}ms]", rows.size(), entityType.getSimpleName(),
                stopWatchThread.get().getLastTaskTimeMillis());
        return rows;
    } finally {
        if (stopWatchThread.get().isRunning())
            stopWatchThread.get().stop();
    }
}

From source file:com.devicehive.dao.rdbms.DeviceDaoRdbmsImpl.java

@Override
public List<DeviceVO> getDeviceList(List<String> guids, HivePrincipal principal) {
    final CriteriaBuilder cb = criteriaBuilder();
    final CriteriaQuery<Device> criteria = cb.createQuery(Device.class);
    final Root<Device> from = criteria.from(Device.class);
    final Predicate[] predicates = CriteriaHelper.deviceListPredicates(cb, from, guids,
            Optional.ofNullable(principal));
    criteria.where(predicates);//w  w  w.ja  v  a 2 s  .  c o m
    final TypedQuery<Device> query = createQuery(criteria);
    CacheHelper.cacheable(query);
    return query.getResultList().stream().map(Device::convertToVo).collect(Collectors.toList());
}

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

@Override
public List<? extends Loan> findLoanUnitsBy(Person loaner) {
    TypedQuery<LoanDomainObject> query = entityManager.createNamedQuery("findLoanUnitsByPerson",
            LoanDomainObject.class);
    query.setParameter("loaner", loaner);
    return query.getResultList();
}

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

@Override
public List<? extends Person> findPersonsByTitle(String title) {
    TypedQuery<PersonDomainObject> query = entityManager.createNamedQuery("findPersonsByTitle",
            PersonDomainObject.class);
    query.setParameter("title", title);
    return query.getResultList();
}

From source file:com.smhdemo.common.report.dao.CategoryDao.java

public Boolean findTextIsEntityByTextAndCategory(final Long textReportId, final Long categoryReportId) {
    String hql = "Select c From Category As c Left Join c.texts As t Where t.id=:textReportId And c.id=:categoryReportId";

    TypedQuery<Category> query = this.getEntityManager().createQuery(hql, Category.class);
    query.setParameter("textReportId", textReportId);
    query.setParameter("categoryReportId", categoryReportId);

    List<Category> list = query.getResultList();
    return list.isEmpty() ? false : true;
}

From source file:org.mitre.oauth2.repository.impl.JpaSystemScopeRepository.java

@Override
@Transactional(value = "defaultTransactionManager")
public SystemScope getByValue(String value) {
    TypedQuery<SystemScope> query = em.createNamedQuery(SystemScope.QUERY_BY_VALUE, SystemScope.class);
    query.setParameter(SystemScope.PARAM_VALUE, value);
    return getSingleResult(query.getResultList());
}

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

/**
 * {@inheritDoc}//  w  w  w.  j a  v a  2s .  c  o  m
 */
public Customer getCustomerByUserName(final String userName) {
    TypedQuery<Customer> query = entityManager.createNamedQuery("findCustomerByUserName", Customer.class);
    query.setParameter("p_userName", userName);
    List<Customer> customers = query.getResultList();
    return (customers != null && !customers.isEmpty()) ? customers.get(0) : null;
}

From source file:com.smhdemo.common.report.dao.CategoryDao.java

public Boolean findChartIsEntityByChartAndCategory(final Long chartReportId, final Long categoryReportId) {
    String hql = "Select c From Category As c Left Join c.charts As t Where t.id=:chartReportId And c.id=:categoryReportId";

    TypedQuery<Category> query = this.getEntityManager().createQuery(hql, Category.class);
    query.setParameter("chartReportId", chartReportId);
    query.setParameter("categoryReportId", categoryReportId);

    List<Category> list = query.getResultList();
    return list.isEmpty() ? false : true;
}

From source file:rzd.vivc.documentexamination.repository.AccountRepositoryImpl.java

@Override
public Account findWithDependencies(Long userID) {
    TypedQuery createQuery = em.createQuery(
            "SELECT a FROM Account a LEFT JOIN FETCH a.user u LEFT JOIN FETCH u.department  WHERE u.id=:id",
            Account.class);
    createQuery.setParameter("id", userID);
    return (Account) createQuery.getResultList().get(0);
}