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.institution.db.HbInstitutionalItemDAO.java

License:Apache License

/**
 * Get a list of items for a specified repository by between the that have titles
 * that start between the specified characters with the given content type id
 * //from ww w.  java2s .  c o  m
 * @param rowStart - Start row to fetch the data from
 * @param maxResulsts - maximum number of results to fetch
 * @param repositoryId - id of the repository to get items 
 * @param firstChar - first character in range that the first letter of the name can have
 * @param lastChar - last character in range that the first letter of the name can have
 * @param orderType - The order to sort by (asc/desc)
 * 
 * @return List of institutional items
 * @see edu.ur.ir.institution.InstitutionalItemDAO#getRepositoryItemsBetweenChar(int, int, java.lang.Long, char, char, java.lang.Long, edu.ur.order.OrderType)
 */
@SuppressWarnings("unchecked")
public List<InstitutionalItem> getRepositoryItemsBetweenCharFirstAvailableOrder(int rowStart, int maxResults,
        Long repositoryId, char firstChar, char lastChar, OrderType orderType) {
    Session session = hbCrudDAO.getSessionFactory().getCurrentSession();
    Query q = null;
    if (orderType.equals(OrderType.DESCENDING_ORDER)) {
        q = session.getNamedQuery("getRepositoryItemsByCharRangeFirstAvailableOrderDesc");
    } else {
        q = session.getNamedQuery("getRepositoryItemsByCharRangeFirstAvailableOrderAsc");
    }

    q.setParameter("repositoryId", repositoryId);
    q.setParameter("firstChar", Character.valueOf(Character.toLowerCase(firstChar)));
    q.setParameter("lastChar", Character.valueOf(Character.toLowerCase(lastChar)));
    q.setFirstResult(rowStart);
    q.setMaxResults(maxResults);
    q.setFetchSize(maxResults);
    return q.list();
}

From source file:edu.ur.hibernate.ir.institution.db.HbInstitutionalItemDAO.java

License:Apache License

/**
 * Get a list of items for a specified repository by between the that have titles
 * that start between the specified characters with the given content type id
 * /*from  w  ww  . j  a  va  2  s  .  c om*/
 * @param rowStart - Start row to fetch the data from
 * @param maxResulsts - maximum number of results to fetch
 * @param repositoryId - id of the repository to get items 
 * @param firstChar - first character in range that the first letter of the name can have
 * @param lastChar - last character in range that the first letter of the name can have
 * @param contentTypeId - id of the content type
 * @param orderType - The order to sort by (asc/desc)
 * 
 * @return List of institutional items
 * @see edu.ur.ir.institution.InstitutionalItemDAO#getRepositoryItemsBetweenChar(int, int, java.lang.Long, char, char, java.lang.Long, edu.ur.order.OrderType)
 */
@SuppressWarnings("unchecked")
public List<InstitutionalItem> getRepositoryItemsBetweenCharFirstAvailableOrder(int rowStart, int maxResults,
        Long repositoryId, char firstChar, char lastChar, Long contentTypeId, OrderType orderType) {
    Session session = hbCrudDAO.getSessionFactory().getCurrentSession();
    Query q = null;
    if (orderType.equals(OrderType.DESCENDING_ORDER)) {
        q = session.getNamedQuery("getRepositoryItemsContentTypeByCharRangeFirstAvailableOrderDesc");
    } else {
        q = session.getNamedQuery("getRepositoryItemsContentTypeByCharRangeFirstAvailableOrderAsc");
    }

    q.setParameter("repositoryId", repositoryId);
    q.setParameter("firstChar", Character.valueOf(Character.toLowerCase(firstChar)));
    q.setParameter("lastChar", Character.valueOf(Character.toLowerCase(lastChar)));
    q.setParameter("contentTypeId", contentTypeId);
    q.setFirstResult(rowStart);
    q.setMaxResults(maxResults);
    q.setFetchSize(maxResults);
    return q.list();
}

From source file:edu.ur.hibernate.ir.institution.db.HbInstitutionalItemDAO.java

License:Apache License

/**
 * Get a list of items for a specified repository by first character of the name and
 * the given content type id//from  w  w  w.j  a v  a 2s  .c  om
 * 
 * @param rowStart - Start row to fetch the data from
 * @param maxResults - maximum number of results to fetch
 * @param repositoryId - id of the repository to get items 
 * @param firstChar - first character that the name should have
 * @param orderType - The order to sort by (asc/desc)
 * 
 * @return List of institutional items
 */
@SuppressWarnings("unchecked")
public List<InstitutionalItem> getRepositoryItemsByCharFirstAvailableOrder(int rowStart, int maxResults,
        Long repositoryId, char firstChar, OrderType orderType) {
    Session session = hbCrudDAO.getSessionFactory().getCurrentSession();
    Query q = null;
    if (orderType.equals(OrderType.DESCENDING_ORDER)) {
        q = session.getNamedQuery("getRepositoryItemsByCharFirstAvailableOrderDesc");
    } else {
        q = session.getNamedQuery("getRepositoryItemsByCharFirstAvailableOrderAsc");
    }

    q.setParameter("repositoryId", repositoryId);
    q.setParameter("firstChar", Character.valueOf(Character.toLowerCase(firstChar)));
    q.setFirstResult(rowStart);
    q.setMaxResults(maxResults);
    q.setFetchSize(maxResults);
    return q.list();
}

From source file:edu.ur.hibernate.ir.institution.db.HbInstitutionalItemDAO.java

License:Apache License

/**
 * Get a list of items for a specified repository by first character of the name and
 * the given content type id/* w ww .j a v  a2s  .  c  o  m*/
 * 
 * @param rowStart - Start row to fetch the data from
 * @param maxResults - maximum number of results to fetch
 * @param repositoryId - id of the repository to get items 
 * @param contentTypeId - id of the content type
 * @param firstChar - first character that the name should have
 * @param orderType - The order to sort by (asc/desc)
 * 
 * @return List of institutional items
 */
@SuppressWarnings("unchecked")
public List<InstitutionalItem> getRepositoryItemsByCharFirstAvailableOrder(int rowStart, int maxResults,
        Long repositoryId, Long contentTypeId, char firstChar, OrderType orderType) {
    Session session = hbCrudDAO.getSessionFactory().getCurrentSession();
    Query q = null;
    if (orderType.equals(OrderType.DESCENDING_ORDER)) {
        q = session.getNamedQuery("getRepositoryItemsContentTypeByCharFirstAvailableOrderDesc");
    } else {
        q = session.getNamedQuery("getRepositoryItemsContentTypeByCharFirstAvailableOrderAsc");
    }

    q.setParameter("repositoryId", repositoryId);
    q.setParameter("char", Character.valueOf(Character.toLowerCase(firstChar)));
    q.setParameter("contentTypeId", contentTypeId);
    q.setFirstResult(rowStart);
    q.setMaxResults(maxResults);
    q.setFetchSize(maxResults);
    return q.list();
}

From source file:edu.ur.hibernate.ir.institution.db.HbInstitutionalItemVersionDAO.java

License:Apache License

/**
 * Get the  publications for a given set of names ordered by title.
 * /*w w  w  . j  ava2 s  . c om*/
 * @param rowStart - start position
 * @param maxResults - maximum number of results to return
 * @param personNameIds - set of name ids to get 
 * @param orderType - way to order the set
 * @return
 */
@SuppressWarnings("unchecked")
public List<InstitutionalItemVersionDownloadCount> getPublicationVersionsForNamesByTitle(final int rowStart,
        final int maxResults, final List<Long> personNameIds, final OrderType orderType) {

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

    q.setParameterList("personNameIds", personNameIds);
    q.setFirstResult(rowStart);
    q.setMaxResults(maxResults);
    q.setFetchSize(maxResults);
    return (List<InstitutionalItemVersionDownloadCount>) q.list();
}

From source file:edu.ur.hibernate.ir.institution.db.HbInstitutionalItemVersionDAO.java

License:Apache License

/**
 * Get the  publications for a given set of names by title.
 * /*from   w  w w. j a  va2  s  .  co  m*/
 * @param rowStart - start position
 * @param maxResults - maximum number of results to return
 * @param personNameIds - set of name ids to get 
 * @param orderType - way to order the set
 * @return
 */
@SuppressWarnings("unchecked")
public List<InstitutionalItemVersionDownloadCount> getPublicationVersionsForNamesByDownload(final int rowStart,
        final int maxResults, final List<Long> personNameIds, final OrderType orderType) {
    Query q = null;
    if (orderType.equals(OrderType.DESCENDING_ORDER)) {
        q = hbCrudDAO.getSessionFactory().getCurrentSession()
                .getNamedQuery("getPublicationVersionsByPersonNameIdDownloadDesc");
    } else {
        q = hbCrudDAO.getSessionFactory().getCurrentSession()
                .getNamedQuery("getPublicationVersionsByPersonNameIdDownloadAsc");
    }

    q.setParameterList("personNameIds", personNameIds);
    q.setFirstResult(rowStart);
    q.setMaxResults(maxResults);
    q.setFetchSize(maxResults);
    return (List<InstitutionalItemVersionDownloadCount>) q.list();
}

From source file:edu.ur.hibernate.ir.institution.db.HbInstitutionalItemVersionDAO.java

License:Apache License

/**
 * (non-Javadoc)//from  w  w w . j  av  a  2s  .  co  m
 * 
 * @see edu.ur.ir.institution.InstitutionalItemDAO#getItemsBySponsorItemNameOrder(int,
 *      int, long, edu.ur.order.OrderType)
 */
@SuppressWarnings("unchecked")
public List<InstitutionalItemVersionDownloadCount> getItemsBySponsorItemNameOrder(final int rowStart,
        final int maxResults, final long sponsorId, final OrderType orderType) {
    Query q = null;
    if (orderType.equals(OrderType.DESCENDING_ORDER)) {
        q = hbCrudDAO.getSessionFactory().getCurrentSession().getNamedQuery("getPublicationsForSponsorDesc");
    } else {
        q = hbCrudDAO.getSessionFactory().getCurrentSession().getNamedQuery("getPublicationsForSponsorAsc");
    }

    q.setLong("sponsorId", sponsorId);
    q.setFirstResult(rowStart);
    q.setMaxResults(maxResults);
    q.setFetchSize(maxResults);
    return (List<InstitutionalItemVersionDownloadCount>) q.list();
}

From source file:edu.ur.hibernate.ir.institution.db.HbInstitutionalItemVersionDAO.java

License:Apache License

/**
 * Get items by sponsor item deposit date order.
 * // w  w  w  . ja  v a  2 s  .  co m
 * @see edu.ur.ir.institution.InstitutionalItemVersionDAO#getItemsBySponsorItemDepositDateOrder(int,
 *      int, long, edu.ur.order.OrderType)
 */
@SuppressWarnings("unchecked")
public List<InstitutionalItemVersionDownloadCount> getItemsBySponsorItemDepositDateOrder(final int rowStart,
        final int maxResults, final long sponsorId, final OrderType orderType) {
    Query q = null;
    if (orderType.equals(OrderType.DESCENDING_ORDER)) {
        q = hbCrudDAO.getSessionFactory().getCurrentSession()
                .getNamedQuery("getPublicationsForSponsorDepositDateDesc");
    } else {
        q = hbCrudDAO.getSessionFactory().getCurrentSession()
                .getNamedQuery("getPublicationsForSponsorDepositDateAsc");
    }

    q.setLong("sponsorId", sponsorId);
    q.setFirstResult(rowStart);
    q.setMaxResults(maxResults);
    q.setFetchSize(maxResults);
    return (List<InstitutionalItemVersionDownloadCount>) q.list();
}

From source file:edu.ur.hibernate.ir.institution.db.HbInstitutionalItemVersionDAO.java

License:Apache License

/**
 * Get items by sponsor item deposit download order.
 * //from w  w  w .j  ava2 s.  co  m
 * @see edu.ur.ir.institution.InstitutionalItemVersionDAO#getItemsBySponsorItemDepositDateOrder(int, int, long, edu.ur.order.OrderType)
 */
@SuppressWarnings("unchecked")
public List<InstitutionalItemVersionDownloadCount> getItemsBySponsorItemDownloadOrder(final int rowStart,
        final int maxResults, final long sponsorId, final OrderType orderType) {
    Query q = null;
    if (orderType.equals(OrderType.DESCENDING_ORDER)) {
        q = hbCrudDAO.getSessionFactory().getCurrentSession()
                .getNamedQuery("getPublicationsSponsorDownloadCountOrderByCountDesc");
    } else {
        q = hbCrudDAO.getSessionFactory().getCurrentSession()
                .getNamedQuery("getPublicationsSponsorDownloadCountOrderByCountAsc");
    }

    q.setLong("sponsorId", sponsorId);
    q.setFirstResult(rowStart);
    q.setMaxResults(maxResults);
    q.setFetchSize(maxResults);
    return (List<InstitutionalItemVersionDownloadCount>) q.list();
}

From source file:edu.ur.hibernate.ir.institution.db.HbInstitutionalItemVersionDAO.java

License:Apache License

/**
 * Get list of downloads by submission date.
 * /*from   ww  w . j  a v  a  2  s .  c  o  m*/
 * @see edu.ur.ir.institution.InstitutionalItemVersionDAO#getPublicationVersionsForNamesBySubmissionDate(int,
 *      int, java.util.List, edu.ur.order.OrderType)
 */
@SuppressWarnings("unchecked")
public List<InstitutionalItemVersionDownloadCount> getPublicationVersionsForNamesBySubmissionDate(
        final int rowStart, final int maxResults, final List<Long> personNameIds, final OrderType orderType) {
    Query q = null;
    if (orderType.equals(OrderType.DESCENDING_ORDER)) {
        q = hbCrudDAO.getSessionFactory().getCurrentSession()
                .getNamedQuery("getPublicationVersionsByPersonNameIdSubmissionDateDesc");
    } else {
        q = hbCrudDAO.getSessionFactory().getCurrentSession()
                .getNamedQuery("getPublicationVersionsByPersonNameIdSubmissionDateAsc");
    }

    q.setParameterList("personNameIds", personNameIds);
    q.setFirstResult(rowStart);
    q.setMaxResults(maxResults);
    q.setFetchSize(maxResults);
    return (List<InstitutionalItemVersionDownloadCount>) q.list();
}