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.item.db.HbContentTypeDAO.java

License:Apache License

/**
 * Get the content type order by name./*from w w  w .ja va2s  .c o m*/
 * 
 * @see edu.ur.ir.item.ContentTypeDAO#getContentTypesOrderByName(int, int, String)
 */
@SuppressWarnings("unchecked")
public List<ContentType> getContentTypesOrderByName(final int rowStart, final int numberOfResultsToShow,
        final String sortType) {
    List<ContentType> contentTypes = (List<ContentType>) hbCrudDAO.getHibernateTemplate()
            .execute(new HibernateCallback() {
                public Object doInHibernate(Session session) throws HibernateException, SQLException {

                    Query q = null;
                    if (sortType.equalsIgnoreCase("asc")) {
                        q = session.getNamedQuery("getContentTypesOrderByNameAsc");
                    } else {
                        q = session.getNamedQuery("getContentTypesOrderByNameDesc");
                    }

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

            });

    return contentTypes;
}

From source file:edu.ur.hibernate.ir.item.db.HbCopyrightStatementDAO.java

License:Apache License

/**
 * Get the copyright statements ordered by name.
 * // www  .j  a  va2 s  . c o  m
 * @see edu.ur.ir.item.ContentTypeDAO#getContentTypesOrderByName(int, int, String)
 */
@SuppressWarnings("unchecked")
public List<CopyrightStatement> getCopyrightStatementsOrderByName(final int rowStart,
        final int numberOfResultsToShow, final OrderType orderType) {
    List<CopyrightStatement> copyrightStatements = (List<CopyrightStatement>) 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("getCopyrightStatementByNameAsc");
                    } else {
                        q = session.getNamedQuery("getCopyrightStatementByNameDesc");
                    }

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

            });

    return copyrightStatements;
}

From source file:edu.ur.hibernate.ir.item.db.HbExtentTypeDAO.java

License:Apache License

/**
 * Get extent types.//w ww . j a  v a2 s. c  om
 * 
 * @see edu.ur.ir.item.ExtentTypeDAO#getExtentTypesOrderByName(int, int, String)
 */
@SuppressWarnings("unchecked")
public List<ExtentType> getExtentTypesOrderByName(final int rowStart, final int numberOfResultsToShow,
        final String sortType) {
    List<ExtentType> extentTypes = (List<ExtentType>) hbCrudDAO.getHibernateTemplate()
            .execute(new HibernateCallback() {
                public Object doInHibernate(Session session) throws HibernateException, SQLException {
                    Query q = null;
                    if (sortType.equalsIgnoreCase("asc")) {
                        q = session.getNamedQuery("getExtentTypesOrderByNameAsc");
                    } else {
                        q = session.getNamedQuery("getExtentTypesOrderByNameDesc");
                    }

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

    return extentTypes;
}

From source file:edu.ur.hibernate.ir.item.db.HbIdentifierTypeDAO.java

License:Apache License

/**
 * Get identifier types.//from  w  ww.  ja v a2  s.co m
 * 
 * @see edu.ur.ir.item.IdentifierTypeDAO#getIdentifierTypesOrderByName( int, int, String)
 */
@SuppressWarnings("unchecked")
public List<IdentifierType> getIdentifierTypesOrderByName(final int rowStart, final int numberOfResultsToShow,
        final String sortType) {
    List<IdentifierType> identifierTypes = (List<IdentifierType>) hbCrudDAO.getHibernateTemplate()
            .execute(new HibernateCallback() {
                public Object doInHibernate(Session session) throws HibernateException, SQLException {
                    Query q = null;
                    if (sortType.equalsIgnoreCase("asc")) {
                        q = session.getNamedQuery("getIdentifierTypesOrderByNameAsc");
                    } else {
                        q = session.getNamedQuery("getIdentifierTypesOrderByNameDesc");
                    }

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

From source file:edu.ur.hibernate.ir.item.db.HbLanguageTypeDAO.java

License:Apache License

/**
 * Get the language types order by name.
 * /*from   www . ja  v a 2s  .  c  om*/
 * @see edu.ur.ir.item.LanguageTypeDAO#getLanguageTypesOrderByName(int, int, String)
 */
@SuppressWarnings("unchecked")
public List<LanguageType> getLanguageTypesOrderByName(final int rowStart, final int numberOfResultsToShow,
        final String sortType) {
    List<LanguageType> languageTypes = (List<LanguageType>) hbCrudDAO.getHibernateTemplate()
            .execute(new HibernateCallback() {
                public Object doInHibernate(Session session) throws HibernateException, SQLException {
                    Query q = null;
                    if (sortType.equalsIgnoreCase("asc")) {
                        q = session.getNamedQuery("getLanguageTypesOrderByNameAsc");
                    } else {
                        q = session.getNamedQuery("getLanguageTypesOrderByNameDesc");
                    }

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

    return languageTypes;

}

From source file:edu.ur.hibernate.ir.item.db.HbPublisherDAO.java

License:Apache License

@SuppressWarnings("unchecked")
public List<Publisher> getPublishersOrderByName(final int rowStart, final int numberOfResultsToShow,
        final String sortType) {
    List<Publisher> publishers = (List<Publisher>) hbCrudDAO.getHibernateTemplate()
            .execute(new HibernateCallback() {
                public Object doInHibernate(Session session) throws HibernateException, SQLException {
                    Query q = null;
                    if (sortType.equalsIgnoreCase("asc")) {
                        q = session.getNamedQuery("getPublishersOrderByNameAsc");
                    } else {
                        q = session.getNamedQuery("getPublishersOrderByNameDesc");
                    }//from  w  w  w  .  j a  v  a 2s  .c om

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

From source file:edu.ur.hibernate.ir.item.db.HbSeriesDAO.java

License:Apache License

@SuppressWarnings("unchecked")
public List<Series> getSeriesOrderByName(final int rowStart, final int numberOfResultsToShow,
        final String sortType) {
    List<Series> series = (List<Series>) hbCrudDAO.getHibernateTemplate().execute(new HibernateCallback() {
        public Object doInHibernate(Session session) throws HibernateException, SQLException {
            Query q = null;
            if (sortType.equalsIgnoreCase("asc")) {
                q = session.getNamedQuery("getSeriesOrderByNameAsc");
            } else {
                q = session.getNamedQuery("getSeriesOrderByNameDesc");
            }/*  www. j  a  va  2s .  c  o  m*/

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

From source file:edu.ur.hibernate.ir.item.db.HbSponsorDAO.java

License:Apache License

@SuppressWarnings("unchecked")
public List<Sponsor> getSponsorsOrderByName(final int rowStart, final int numberOfResultsToShow,
        final OrderType orderType) {
    List<Sponsor> sponsors = (List<Sponsor>) 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("getSponsorsOrderByNameAsc");
            } else {
                q = session.getNamedQuery("getSponsorsOrderByNameDesc");
            }//  www  .  ja v a  2  s .c  om

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

From source file:edu.ur.hibernate.ir.item.db.HbSponsorDAO.java

License:Apache License

/**
 *  //from w  ww. j  av a  2s  .  c  o m
 * @see edu.ur.ir.item.SponsorDAO#getByNameFirstChar(int, int, char, edu.ur.order.OrderType)
 */
@SuppressWarnings("unchecked")
public List<Sponsor> getByNameFirstChar(final int rowStart, final int maxResults, final char firstChar,
        final OrderType orderType) {
    List<Sponsor> sponsors = (List<Sponsor>) 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("getSponsorsOrderByNameFirstCharAsc");
            } else {
                q = session.getNamedQuery("getSponsorsOrderByNameFirstCharDesc");
            }
            q.setCharacter("sponsorFirstChar", Character.toLowerCase(firstChar));
            q.setFirstResult(rowStart);
            q.setMaxResults(maxResults);
            q.setReadOnly(true);
            q.setFetchSize(maxResults);
            return q.list();
        }
    });
    return sponsors;
}

From source file:edu.ur.hibernate.ir.item.db.HbSponsorDAO.java

License:Apache License

/**
 * /*ww w.j a  v a  2 s .co  m*/
 * @see edu.ur.ir.item.SponsorDAO#getSponsorsByNameBetweenChar(int, int, char, char, edu.ur.order.OrderType)
 */
@SuppressWarnings("unchecked")
public List<Sponsor> getSponsorsByNameBetweenChar(final int rowStart, final int maxResults,
        final char firstChar, final char lastChar, final OrderType orderType) {
    List<Sponsor> sponsors = (List<Sponsor>) 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("getSponsorsOrderByNameFirstCharRangeAsc");
            } else {
                q = session.getNamedQuery("getSponsorsOrderByNameFirstCharRangeDesc");
            }
            q.setCharacter("firstChar", Character.toLowerCase(firstChar));
            q.setCharacter("secondChar", Character.toLowerCase(lastChar));
            q.setFirstResult(rowStart);
            q.setMaxResults(maxResults);
            q.setReadOnly(true);
            q.setFetchSize(maxResults);
            return q.list();
        }
    });
    return sponsors;
}