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:br.ufrgs.inf.dsmoura.repository.model.dao.TypesDAO.java

public List<OperationalSystemTypeDTO> getOperationalSystemTypeDTOList() {
    TypedQuery<OperationalSystemTypeDTO> query = createEntityManager()
            .createQuery("SELECT t FROM OperationalSystemTypeDTO t", OperationalSystemTypeDTO.class);
    return query.getResultList();
}

From source file:org.openmeetings.app.data.user.dao.UsersDaoImpl.java

public List<Users> getAllUsersDeleted() {
    try {//  w  w  w.ja  va 2  s.co m
        TypedQuery<Users> q = em.createNamedQuery("getAllUsers", Users.class);
        return q.getResultList();
    } catch (Exception ex2) {
        log.error("[getAllUsersDeleted] ", ex2);
    }
    return null;
}

From source file:cz.fi.muni.pa165.dao.PrintedBookDAOImpl.java

@Override
public List<PrintedBook> findAllPrintedBooksByLoan(Loan loan) {
    if (loan == null) {
        throw new IllegalArgumentException("Book null");
    }// ww w .  ja va2  s . c om

    try {
        final TypedQuery<PrintedBook> query = em
                .createQuery("SELECT m FROM PrintedBook as m WHERE m.loan.idLoan = :lid", PrintedBook.class);
        query.setParameter("lid", loan.getIdLoan());
        return query.getResultList();
    } catch (RuntimeException E) {
        throw new DAException(E.getMessage());
    }
}

From source file:com.epam.training.taranovski.web.project.repository.implementation.VacancyRepositoryImplementation.java

@Override
public List<VacancySkill> getSkills(Vacancy vacancy) {
    EntityManager em = entityManagerFactory.createEntityManager();
    List<VacancySkill> list = new LinkedList<>();
    try {/*  ww w  .  j av a2 s .co  m*/
        em.getTransaction().begin();

        TypedQuery<VacancySkill> query = em.createNamedQuery("VacancySkill.findByVacancy", VacancySkill.class);
        query.setParameter("vacancy", vacancy);
        list = query.getResultList();

        em.getTransaction().commit();
    } catch (RuntimeException e) {
        Logger.getLogger(VacancyRepositoryImplementation.class.getName()).info(e);
    } finally {
        if (em.getTransaction().isActive()) {
            em.getTransaction().rollback();
        }
        em.close();
    }

    return list;
}

From source file:br.ufrgs.inf.dsmoura.repository.model.dao.TypesDAO.java

public List<ArtifactDependencyTypeDTO> getArtifactDependencyTypeDTOList() {
    TypedQuery<ArtifactDependencyTypeDTO> query = createEntityManager()
            .createQuery("SELECT t FROM ArtifactDependencyTypeDTO t", ArtifactDependencyTypeDTO.class);
    return query.getResultList();
}

From source file:com.pingdu.dao.licenseDao.LicenseTypeDao.java

/**
 * ?/* w w  w. ja v a 2s  . com*/
 * 
 * @param searchType
 * @param keyword
 * @return
 */
public int calPageSearch(String searchType, String keyword) {
    try {
        String jpql = LicenseTypeSpecSQL(searchType, keyword);
        TypedQuery<LicenseTypeReturn> query = em().createQuery(jpql, LicenseTypeReturn.class);
        //query.setHint(QueryHints.RESULT_TYPE, ResultType.Map);
        int sum = (query.getResultList().size() - 1) / PublicVariable.rows + 1;
        return sum;
    } catch (Exception e) {
        // TODO: handle exception
        System.out.println("?" + e.getMessage());
        return 1;
    }

}

From source file:de.taimos.dao.hibernate.EntityDAOHibernate.java

@Override
public List<E> findList(final int first, final int max) {
    final TypedQuery<E> query = this.entityManager.createQuery(this.getFindListQuery(), this.getEntityClass());
    if (first >= 0) {
        query.setFirstResult(first);//from w  w  w.ja  va 2s . c o m
    }
    if (max >= 0) {
        query.setMaxResults(max);
    }
    return query.getResultList();
}

From source file:io.github.davejoyce.dao.composite.social.connect.jpa.JpaUsersConnectionRepository.java

/**
 * {@inheritDoc}//from  w  w  w. ja  v a  2 s.co m
 */
public Set<String> findUserIdsConnectedTo(String providerId, Set<String> providerUserIds) {
    TypedQuery<AppUserSocialConnection> query = entityManager
            .createQuery(QUERY_FIND_USERIDS_CONNECTED_TO, AppUserSocialConnection.class)
            .setParameter("providerId", providerId).setParameter("providerUserIds", providerUserIds);
    List<AppUserSocialConnection> appUserSocialConnections = query.getResultList();
    Set<String> userIds = new HashSet<String>();
    for (AppUserSocialConnection appUserSocialConnection : appUserSocialConnections) {
        userIds.add(appUserSocialConnection.getAppUser().getUserId());
    }
    return userIds;
}

From source file:net.groupbuy.dao.impl.ArticleCategoryDaoImpl.java

public List<ArticleCategory> findParents(ArticleCategory articleCategory, Integer count) {
    if (articleCategory == null || articleCategory.getParent() == null) {
        return Collections.<ArticleCategory>emptyList();
    }// w ww.j  a  v  a  2 s.c om
    String jpql = "select articleCategory from ArticleCategory articleCategory where articleCategory.id in (:ids) order by articleCategory.grade asc";
    TypedQuery<ArticleCategory> query = entityManager.createQuery(jpql, ArticleCategory.class)
            .setFlushMode(FlushModeType.COMMIT).setParameter("ids", articleCategory.getTreePaths());
    if (count != null) {
        query.setMaxResults(count);
    }
    return query.getResultList();
}

From source file:br.ufrgs.inf.dsmoura.repository.model.dao.TypesDAO.java

public List<InternationalizationTypeDTO> getInternationalizationTypeDTOList() {
    TypedQuery<InternationalizationTypeDTO> query = createEntityManager()
            .createQuery("SELECT t FROM InternationalizationTypeDTO t", InternationalizationTypeDTO.class);
    return query.getResultList();
}