Example usage for org.hibernate.annotations QueryHints FETCH_SIZE

List of usage examples for org.hibernate.annotations QueryHints FETCH_SIZE

Introduction

In this page you can find the example usage for org.hibernate.annotations QueryHints FETCH_SIZE.

Prototype

String FETCH_SIZE

To view the source code for org.hibernate.annotations QueryHints FETCH_SIZE.

Click Source Link

Document

Defines the JDBC fetch size to use.

Usage

From source file:org.dcm4chee.arc.qmgt.impl.QueueManagerEJB.java

License:LGPL

private Iterator<QueueMessage> listQueueMessages(TaskQueryParam queueTaskQueryParam, int fetchSize, int offset,
        int limit) {
    CriteriaBuilder cb = em.getCriteriaBuilder();
    MatchTask matchTask = new MatchTask(cb);
    TypedQuery<QueueMessage> query = em.createQuery(select(cb, matchTask, queueTaskQueryParam));
    if (fetchSize > 0)
        query.setHint(QueryHints.FETCH_SIZE, fetchSize);
    if (offset > 0)
        query.setFirstResult(offset);//  w ww  .  j  a v  a  2s  .  c  om
    if (limit > 0)
        query.setMaxResults(limit);
    return query.getResultStream().iterator();
}