Example usage for org.hibernate Query setFetchSize

List of usage examples for org.hibernate Query setFetchSize

Introduction

In this page you can find the example usage for org.hibernate Query setFetchSize.

Prototype

Query<R> setFetchSize(int fetchSize);

Source Link

Document

Sets a JDBC fetch size hint for the query.

Usage

From source file:edu.ur.hibernate.ir.statistics.db.HbFileDownloadRollUpProcessingRecordDAO.java

License:Apache License

@SuppressWarnings("unchecked")
public List<FileDownloadRollUpProcessingRecord> getProcessingRecords(final int start, final int maxResults) {
    return (List<FileDownloadRollUpProcessingRecord>) hbCrudDAO.getHibernateTemplate()
            .execute(new HibernateCallback() {
                public Object doInHibernate(Session session) throws HibernateException, SQLException {
                    Query q = session.getNamedQuery("getAllFileDownloadRollUpProcessingRecords");
                    q.setReadOnly(true);
                    q.setCacheable(false);
                    q.setFirstResult(start);
                    q.setMaxResults(maxResults);
                    q.setFetchSize(maxResults);
                    return (List<FileDownloadRollUpProcessingRecord>) q.list();
                }/*www. j  av a2  s  .c o  m*/
            });
}

From source file:edu.ur.hibernate.ir.statistics.db.HbIgnoreIpAddressDAO.java

License:Apache License

/**
 * Get the Ignore IpAddresses based on the criteria.
 * //from ww w  . j ava  2 s . co m
 * @see edu.ur.ir.statistics.IgnoreIpAddressDAO#getIgnoreIpAddresses(int, int, String)
 */
@SuppressWarnings("unchecked")
public List<IgnoreIpAddress> getIgnoreIpAddresses(final int rowStart, final int numberOfResultsToShow,
        final String sortType) {
    List<IgnoreIpAddress> ipAddresses = (List<IgnoreIpAddress>) hbCrudDAO.getHibernateTemplate()
            .execute(new HibernateCallback() {
                public Object doInHibernate(Session session) throws HibernateException, SQLException {
                    Query q = null;
                    if (sortType.equalsIgnoreCase("asc")) {
                        q = session.getNamedQuery("getIgnoreIPOrderByNameAsc");
                    } else {
                        q = session.getNamedQuery("getIgnoreIPOrderByNameDesc");
                    }

                    q.setFirstResult(rowStart);
                    q.setMaxResults(numberOfResultsToShow);
                    q.setReadOnly(true);
                    q.setFetchSize(numberOfResultsToShow);
                    return q.list();

                }
            });

    return ipAddresses;
}

From source file:edu.ur.hibernate.ir.statistics.db.HbIpIgnoreFileDownloadInfoDAO.java

License:Apache License

@SuppressWarnings("unchecked")
public List<IpIgnoreFileDownloadInfo> getIgnoreInfoNowAcceptable(final int rowStart, final int maxResults) {

    List<IpIgnoreFileDownloadInfo> foundItems = (List<IpIgnoreFileDownloadInfo>) hbCrudDAO
            .getHibernateTemplate().execute(new HibernateCallback() {
                public Object doInHibernate(Session session) throws HibernateException, SQLException {
                    Query q = session.getNamedQuery("getAcceptableFileDownloadsIgnored");
                    q.setFirstResult(rowStart);
                    q.setMaxResults(maxResults);
                    q.setCacheable(false);
                    q.setReadOnly(true);
                    q.setFetchSize(maxResults);
                    return q.list();
                }/* w  ww. j av  a2 s  .  co  m*/
            });
    return foundItems;
}

From source file:edu.ur.hibernate.ir.statistics.db.HbIpIgnoreFileDownloadInfoDAO.java

License:Apache License

@SuppressWarnings("unchecked")
public List<IpDownloadCount> getIpIgnoreOrderByDownloadCounts(int start, int maxResults, OrderType orderType) {
    Query q = null;
    if (orderType.equals(OrderType.DESCENDING_ORDER)) {
        q = hbCrudDAO.getSessionFactory().getCurrentSession()
                .getNamedQuery("getDownloadInfoIgnoreCountSumDesc");
    } else {/*ww w. j  a  v a  2 s  .  co  m*/
        q = hbCrudDAO.getSessionFactory().getCurrentSession().getNamedQuery("getDownloadInfoIgnoreCountSumAsc");
    }

    q.setFirstResult(start);
    q.setMaxResults(maxResults);
    q.setFetchSize(maxResults);
    return (List<IpDownloadCount>) q.list();
}

From source file:edu.ur.hibernate.ir.user.db.HbAffiliationDAO.java

License:Apache License

@SuppressWarnings("unchecked")
public List<Affiliation> getAffiliations(final int rowStart, final int numberOfResultsToShow,
        final String sortType) {
    List<Affiliation> affiliations = (List<Affiliation>) hbCrudDAO.getHibernateTemplate()
            .execute(new HibernateCallback() {
                public Object doInHibernate(Session session) throws HibernateException, SQLException {
                    Query q = null;
                    if (sortType.equalsIgnoreCase("asc")) {
                        q = session.getNamedQuery("getAffiliationsOrderByNameAsc");
                    } else {
                        q = session.getNamedQuery("getAffiliationsOrderByNameDesc");
                    }/* w  w  w. j a va2 s  . c o m*/

                    q.setFirstResult(rowStart);
                    q.setMaxResults(numberOfResultsToShow);
                    q.setReadOnly(true);
                    q.setFetchSize(numberOfResultsToShow);
                    return q.list();

                }
            });

    return affiliations;
}

From source file:edu.ur.hibernate.ir.user.db.HbDepartmentDAO.java

License:Apache License

@SuppressWarnings("unchecked")
public List<Department> getDepartments(final int rowStart, final int numberOfResultsToShow,
        final String sortType) {
    List<Department> departments = (List<Department>) hbCrudDAO.getHibernateTemplate()
            .execute(new HibernateCallback() {
                public Object doInHibernate(Session session) throws HibernateException, SQLException {
                    Query q = null;
                    if (sortType.equalsIgnoreCase("asc")) {
                        q = session.getNamedQuery("getDepartmentsOrderByNameAsc");
                    } else {
                        q = session.getNamedQuery("getDepartmentsOrderByNameDesc");
                    }/*from w  w  w. j  av a2 s .c o m*/

                    q.setFirstResult(rowStart);
                    q.setMaxResults(numberOfResultsToShow);
                    q.setReadOnly(true);
                    q.setFetchSize(numberOfResultsToShow);
                    return q.list();

                }
            });

    return departments;
}

From source file:edu.ur.hibernate.ir.user.db.HbExternalAccountTypeDAO.java

License:Apache License

/**
 * Get external account types ordered by name.
 * /* w  w w . j av  a2  s.c  om*/
 * @see edu.ur.ir.user.ExternalAccountTypeDAO#getOrderByName(int, int, edu.ur.order.OrderType)
 */
@SuppressWarnings("unchecked")
public List<ExternalAccountType> getOrderByName(final int rowStart, final int numberOfResultsToShow,
        final OrderType orderType) {
    List<ExternalAccountType> externalAccountTypes = (List<ExternalAccountType>) hbCrudDAO
            .getHibernateTemplate().execute(new HibernateCallback() {
                public Object doInHibernate(Session session) throws HibernateException, SQLException {

                    Query q = null;
                    if (orderType.equals(OrderType.ASCENDING_ORDER)) {
                        q = session.getNamedQuery("getExternalAccountTypesOrderByNameAsc");
                    } else {
                        q = session.getNamedQuery("getExternalAccountTypesOrderByNameDesc");
                    }

                    q.setFirstResult(rowStart);
                    q.setMaxResults(numberOfResultsToShow);
                    q.setReadOnly(true);
                    q.setFetchSize(numberOfResultsToShow);
                    return q.list();
                }

            });

    return externalAccountTypes;
}

From source file:edu.ur.hibernate.ir.user.db.HbFileInviteInfoDAO.java

License:Apache License

/**
 * Get the list of invite infos ordered by inviteor
 * /*from   w w  w.  j  a va2 s  .  c  om*/
 * @param rowStart - start position in the list
 * @param maxResults - maximum number of results to retrieve
 * @param orderType - ascending/decending order
 * 
 * @return list of invitees found
 */
@SuppressWarnings("unchecked")
public List<FileInviteInfo> getInviteInfosOrderByInviteor(int rowStart, int maxResults, OrderType orderType) {

    Query q = null;
    if (orderType.equals(OrderType.DESCENDING_ORDER)) {
        q = hbCrudDAO.getSessionFactory().getCurrentSession().getNamedQuery("getInviteInfosOrderByInvitorDesc");
    } else {
        q = hbCrudDAO.getSessionFactory().getCurrentSession().getNamedQuery("getInviteInfosOrderByInvitorAsc");
    }

    q.setFirstResult(rowStart);
    q.setMaxResults(maxResults);
    q.setFetchSize(maxResults);
    return (List<FileInviteInfo>) q.list();
}

From source file:edu.ur.hibernate.ir.user.db.HbFolderInviteInfoDAO.java

License:Apache License

/**
 *  Get the list of folder invite infos ordered by inviteor
 * //from   ww w.  j  a v a  2  s  .c o m
 * @param rowStart - start position in the list
 * @param maxResults - maximum number of results to retrieve
 * @param orderType - ascending/decending order
 * 
 * @see edu.ur.ir.user.FolderInviteInfoDAO#getInviteInfosOrderByInviteor(int, int, edu.ur.order.OrderType)
 */
@SuppressWarnings("unchecked")
public List<FolderInviteInfo> getInviteInfosOrderByInviteor(int rowStart, int maxResults, OrderType orderType) {
    Query q = null;
    if (orderType.equals(OrderType.DESCENDING_ORDER)) {
        q = hbCrudDAO.getSessionFactory().getCurrentSession()
                .getNamedQuery("getFolderInviteInfosOrderByInvitorDesc");
    } else {
        q = hbCrudDAO.getSessionFactory().getCurrentSession()
                .getNamedQuery("getFolderInviteInfosOrderByInvitorAsc");
    }

    q.setFirstResult(rowStart);
    q.setMaxResults(maxResults);
    q.setFetchSize(maxResults);
    return (List<FolderInviteInfo>) q.list();
}

From source file:edu.ur.hibernate.ir.user.db.HbIrRoleDAO.java

License:Apache License

@SuppressWarnings("unchecked")
public List<IrRole> getRoles(final int rowStart, final int numberOfResultsToShow, final String sortType) {
    List<IrRole> roles = (List<IrRole>) hbCrudDAO.getHibernateTemplate().execute(new HibernateCallback() {
        public Object doInHibernate(Session session) throws HibernateException, SQLException {
            Query q = null;
            if (sortType.equalsIgnoreCase("asc")) {
                q = session.getNamedQuery("getRolesOrderByNameAsc");
            } else {
                q = session.getNamedQuery("getRolesOrderByNameDesc");
            }// w  w w  .  j a  v a2  s . c o m

            q.setFirstResult(rowStart);
            q.setMaxResults(numberOfResultsToShow);
            q.setReadOnly(true);
            q.setFetchSize(numberOfResultsToShow);
            return q.list();
        }
    });

    return roles;
}