Example usage for javax.persistence TypedQuery setMaxResults

List of usage examples for javax.persistence TypedQuery setMaxResults

Introduction

In this page you can find the example usage for javax.persistence TypedQuery setMaxResults.

Prototype

TypedQuery<X> setMaxResults(int maxResult);

Source Link

Document

Set the maximum number of results to retrieve.

Usage

From source file:com.jcertif.abj2014.intro.spring.data.before.SpeakerServiceImpl.java

@Override
public List<Speaker> findAll(int page, int pageSize) {
    TypedQuery<Speaker> query = em.createQuery("select s from Speaker s", Speaker.class);

    query.setFirstResult(page * pageSize);
    query.setMaxResults(pageSize);

    return query.getResultList();
}

From source file:csns.model.forum.dao.jpa.ForumDaoImpl.java

@Override
public List<Forum> searchForums(String term, int maxResults) {
    TypedQuery<Forum> query = entityManager.createNamedQuery("forum.search", Forum.class);
    if (maxResults > 0)
        query.setMaxResults(maxResults);
    return query.setParameter("term", term).getResultList();
}

From source file:de.egore911.persistence.selector.AbstractSelector.java

@Nonnull
public List<T> findAll() {
    TypedQuery<T> q = buildQuery();
    if (limit != null) {
        q.setMaxResults(limit);
    }/*  w ww  . j a  va2s  .co m*/
    if (offset != null) {
        q.setFirstResult(offset);
    }
    return q.getResultList();
}

From source file:csns.model.academics.dao.jpa.AssignmentDaoImpl.java

@Override
public List<Assignment> searchAssignments(String term, String type, User instructor, int maxResults) {
    TypedQuery<Assignment> query = entityManager.createNamedQuery("assignment.search", Assignment.class);
    if (maxResults > 0)
        query.setMaxResults(maxResults);

    return query.setParameter("term", term).setParameter("type", type)
            .setParameter("instructorId", instructor.getId()).getResultList();
}

From source file:csns.model.assessment.dao.jpa.RubricDaoImpl.java

@Override
public List<Rubric> searchRubrics(String term, int maxResults) {
    TypedQuery<Rubric> query = entityManager.createNamedQuery("rubric.search", Rubric.class);
    if (maxResults > 0)
        query.setMaxResults(maxResults);
    return query.setParameter("term", term).getResultList();
}

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

public List<LicType_entType> getLicType_entTypeList(int page, int rows) {
    int head = (page - 1) * rows;
    String jpql = "select l from LicType_entType l where 1=1 ";
    TypedQuery<LicType_entType> query = em().createQuery(jpql, LicType_entType.class);
    //query.setHint(QueryHints.RESULT_TYPE, ResultType.Map);
    query.setFirstResult(head);/*w w  w.  j  av a2 s.c o m*/
    query.setMaxResults(rows);
    List<LicType_entType> list = query.getResultList();
    return list;
}

From source file:csns.model.survey.dao.jpa.SurveyDaoImpl.java

@Override
@PreAuthorize("principal.isFaculty(#department.abbreviation)")
public List<Survey> searchSurveys(Department department, String term, int maxResults) {
    TypedQuery<Survey> query = entityManager.createNamedQuery("survey.search", Survey.class);
    if (maxResults > 0)
        query.setMaxResults(maxResults);
    return query.setParameter("departmentId", department.getId()).setParameter("term", term).getResultList();
}

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

public List<ArticleCategory> findRoots(Integer count) {
    String jpql = "select articleCategory from ArticleCategory articleCategory where articleCategory.parent is null order by articleCategory.order asc";
    TypedQuery<ArticleCategory> query = entityManager.createQuery(jpql, ArticleCategory.class);
    if (count != null) {
        query.setMaxResults(count);
    }/*from  w  ww.j  a  va2s. c o  m*/
    return query.getResultList();
}

From source file:net.shopxx.dao.impl.ProductCategoryDaoImpl.java

public List<ProductCategory> findRoots(Integer count) {
    String jpql = "select productCategory from ProductCategory productCategory where productCategory.parent is null order by productCategory.order asc";
    TypedQuery<ProductCategory> query = entityManager.createQuery(jpql, ProductCategory.class);
    if (count != null) {
        query.setMaxResults(count);
    }//from  w  w  w  .j a  v  a 2 s  . c om
    return query.getResultList();
}

From source file:example.springdata.jpa.showcase.before.CustomerServiceImpl.java

@Override
public List<Customer> findAll(int page, int pageSize) {

    TypedQuery<Customer> query = em.createQuery("select c from Customer c", Customer.class);

    query.setFirstResult(page * pageSize);
    query.setMaxResults(pageSize);

    return query.getResultList();
}