Example usage for org.hibernate.internal CriteriaImpl setFirstResult

List of usage examples for org.hibernate.internal CriteriaImpl setFirstResult

Introduction

In this page you can find the example usage for org.hibernate.internal CriteriaImpl setFirstResult.

Prototype

@Override
    public Criteria setFirstResult(int firstResult) 

Source Link

Usage

From source file:org.candlepin.model.DetachedCandlepinQuery.java

License:Open Source License

/**
 * Retreives an executable criteria and configures it to be ready to run the criteria with the
 * configuration set by this criteria instance.
 *
 * @return//from ww  w  . j ava2  s. co m
 *  a fully configured, executable criteria
 */
protected Criteria getExecutableCriteria() {
    // Impl/sadness note:
    // As of Hibernate 5.0, this does not actually result in a new criteria instance -- it just
    // returns its internal CriteriaImpl instance. Changes we make will be reflected between
    // calls.
    CriteriaImpl executable = (CriteriaImpl) this.criteria.getExecutableCriteria(this.session);

    // Restore our initial state
    this.copyFields(this.initialState, executable, true);

    // Set the session again since we just clobbered it.
    executable.setSession((SessionImplementor) this.session);

    if (this.offset > -1) {
        executable.setFirstResult(this.offset);
    }

    if (this.limit > -1) {
        executable.setMaxResults(this.limit);
    }

    if (this.lockMode != null) {
        executable.setLockMode(this.lockMode);
    }

    // TODO: Add read-only when we have a requirement to do so.

    return executable;
}