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
 * // w w w  .ja v  a 2  s.  com
 * NOTE: This search includes all items in child collections
 * 
 * @param rowStart - Start row to fetch the data from
 * @param maxResulsts - maximum number of results to fetch
 * @param collection - the institutional collection 
 * @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 items matching the specified criteria
 * 
 * @see edu.ur.ir.institution.InstitutionalItemDAO#getCollectionItemsBetweenChar(int, int, edu.ur.ir.institution.InstitutionalCollection, java.lang.Long, char, char, edu.ur.order.OrderType)
 */
@SuppressWarnings("unchecked")
public List<InstitutionalItem> getCollectionItemsBetweenCharPublicationDateOrder(int rowStart, int maxResults,
        InstitutionalCollection collection, char firstChar, char lastChar, OrderType orderType) {
    Query q = null;
    if (orderType.equals(OrderType.DESCENDING_ORDER)) {
        q = hbCrudDAO.getSessionFactory().getCurrentSession()
                .getNamedQuery("getInstitutionalCollectionItemsByCharRangePublicationDateOrderDesc");
    } else {
        q = hbCrudDAO.getSessionFactory().getCurrentSession()
                .getNamedQuery("getInstitutionalCollectionItemsByCharRangePublicationDateOrderAsc");
    }

    q.setLong("leftVal", collection.getLeftValue());
    q.setLong("rightVal", collection.getRightValue());
    q.setLong("rootId", collection.getTreeRoot().getId());
    q.setCharacter("firstChar", Character.toLowerCase(firstChar));
    q.setCharacter("lastChar", 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
 * //  w  w  w. j  a  v a 2  s  .  c  o m
 * NOTE: This search includes all items in child collections
 * 
 * @param rowStart - Start row to fetch the data from
 * @param maxResulsts - maximum number of results to fetch
 * @param collection - the institutional collection 
 * @param contentTypeId - content type id the items must have
 * @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 items matching the specified criteria
 * 
 * @see edu.ur.ir.institution.InstitutionalItemDAO#getCollectionItemsBetweenChar(int, int, edu.ur.ir.institution.InstitutionalCollection, java.lang.Long, char, char, edu.ur.order.OrderType)
 */
@SuppressWarnings("unchecked")
public List<InstitutionalItem> getCollectionItemsBetweenCharPublicationDateOrder(int rowStart, int maxResults,
        InstitutionalCollection collection, Long contentTypeId, char firstChar, char lastChar,
        OrderType orderType) {
    Session session = hbCrudDAO.getSessionFactory().getCurrentSession();
    Query q = null;
    if (orderType.equals(OrderType.DESCENDING_ORDER)) {
        q = session.getNamedQuery("getCollectionItemsContentTypeByCharRangePublicationDateOrderDesc");
    } else {
        q = session.getNamedQuery("getCollectionItemsContentTypeByCharRangePublicationDateOrderAsc");
    }

    q.setParameter("leftVal", collection.getLeftValue());
    q.setParameter("rightVal", collection.getRightValue());
    q.setParameter("rootId", collection.getTreeRoot().getId());
    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 collection by first character of the name
 * /*from w w  w.  j a va  2  s  .  c o m*/
 * NOTE: This search includes all items in child collections
 * 
 * @param rowStart - Start row to fetch the data from
 * @param maxResulsts - maximum number of results to fetch
 * @param institutional collection - the institutional collection 
 * @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> getCollectionItemsByCharPublicationDateOrder(int rowStart, int maxResults,
        InstitutionalCollection collection, char firstChar, OrderType orderType) {
    Session session = hbCrudDAO.getSessionFactory().getCurrentSession();

    Query q = null;
    if (orderType.equals(OrderType.DESCENDING_ORDER)) {
        q = session.getNamedQuery("getInstitutionalCollectionItemsByCharPublicationDateOrderDesc");
    } else {
        q = session.getNamedQuery("getInstitutionalCollectionItemsByCharPublicationDateOrderAsc");
    }

    q.setLong("leftVal", collection.getLeftValue());
    q.setLong("rightVal", collection.getRightValue());
    q.setLong("rootId", collection.getTreeRoot().getId());
    q.setCharacter("firstChar", 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 collection by first character of the name
 * /* w  w w  .  j av a  2  s. com*/
 * NOTE: This search includes all items in child collections
 * 
 * @param rowStart - Start row to fetch the data from
 * @param maxResulsts - maximum number of results to fetch
 * @param institutional collection - the institutional collection 
 * @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> getCollectionItemsByCharPublicationDateOrder(int rowStart, int maxResults,
        InstitutionalCollection collection, Long contentTypeId, char firstChar, OrderType orderType) {
    Session session = hbCrudDAO.getSessionFactory().getCurrentSession();
    Query q = null;
    if (orderType.equals(OrderType.DESCENDING_ORDER)) {
        q = session.getNamedQuery("getInstitutionalCollectionItemsContentTypeByCharPublicationDateOrderDesc");
    } else {
        q = session.getNamedQuery("getInstitutionalCollectionItemsContentTypeByCharPublicationDateOrderAsc");
    }

    q.setParameter("leftVal", collection.getLeftValue());
    q.setParameter("rightVal", collection.getRightValue());
    q.setParameter("rootId", collection.getTreeRoot().getId());
    q.setParameter("firstChar", 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.HbInstitutionalItemDAO.java

License:Apache License

/**
 * Get the list of items for the specified collection.  
 * This includes items in child collections
 * //from ww w  . j  a v  a 2s  .  com
 * @param rowStart - Start row to fetch the data from
 * @param maxResults -  maximum number of results to return
 * @param collection - the collection to get items 
 * @param orderType - The order to sort by (ascending/descending)
 * 
 * @return List of institutional items
 */
@SuppressWarnings("unchecked")
public List<InstitutionalItem> getCollectionItemsPublicationDateOrder(int rowStart, int maxResults,
        InstitutionalCollection collection, OrderType orderType) {
    Session session = hbCrudDAO.getSessionFactory().getCurrentSession();
    Query q = null;
    if (orderType.equals(OrderType.DESCENDING_ORDER)) {
        q = session.getNamedQuery("getInstitutionalCollectionItemsPublicationDateOrderDesc");
    } else {
        q = session.getNamedQuery("getInstitutionalCollectionItemsPublicationDateOrderAsc");
    }

    q.setLong("leftVal", collection.getLeftValue());
    q.setLong("rightVal", collection.getRightValue());
    q.setLong("rootId", collection.getTreeRoot().getId());
    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 the list of items for the specified collection with the given 
 * content type id.  This includes items in child collections
 * /* w w w. java 2s .c  o  m*/
 * @param rowStart - Start row to fetch the data from
 * @param maxResults -  maximum number of results to return
 * @param collection - the collection to get items 
 * @param contentTypeId - id of the content type
 * @param orderType - The order to sort by (ascending/descending)
 * 
 * @return List of institutional items
 */
@SuppressWarnings("unchecked")
public List<InstitutionalItem> getCollectionItemsPublicationDateOrder(int rowStart, int maxResults,
        InstitutionalCollection collection, Long contentTypeId, OrderType orderType) {
    Session session = hbCrudDAO.getSessionFactory().getCurrentSession();
    Query q = null;
    if (orderType.equals(OrderType.DESCENDING_ORDER)) {
        q = session.getNamedQuery("getInstitutionalCollectionItemsContentTypeByPublicationDateOrderDesc");
    } else {
        q = session.getNamedQuery("getInstitutionalCollectionItemsContentTypeByPublicationDateOrderAsc");
    }

    q.setLong("leftVal", collection.getLeftValue());
    q.setLong("rightVal", collection.getRightValue());
    q.setLong("rootId", collection.getTreeRoot().getId());
    q.setLong("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 between the that have titles
 * that start between the specified characters
 * /*w  w w.j  a va  2 s  . co 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
 */
@SuppressWarnings("unchecked")
public List<InstitutionalItem> getRepositoryItemsBetweenCharPublicationDateOrder(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("getRepositoryItemsByCharRangePublicationDateOrderDesc");
    } else {
        q = session.getNamedQuery("getRepositoryItemsByCharRangePublicationDateOrderAsc");
    }
    q.setLong("repositoryId", repositoryId);
    q.setCharacter("firstChar", Character.toLowerCase(firstChar));
    q.setCharacter("lastChar", 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 w w .  ja v a 2s . 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 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> getRepositoryItemsBetweenCharPublicationDateOrder(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("getRepositoryItemsContentTypeByCharRangeOrderDesc");
    } else {
        q = session.getNamedQuery("getRepositoryItemsContentTypeByCharRangeOrderAsc");
    }

    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  ww.j  a v  a2 s.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 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> getRepositoryItemsByCharPublicationDateOrder(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("getRepositoryItemsContentTypeByCharPublicationDateOrderDesc");
    } else {
        q = session.getNamedQuery("getRepositoryItemsContentTypeByCharPublicationDateOrderAsc");
    }

    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.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 
 * /*w w  w.j a  va  2  s . 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
 */
@SuppressWarnings("unchecked")
public List<InstitutionalItem> getRepositoryItemsByCharPublicationDateOrder(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("getRepositoryItemsByCharPublicationDateOrderDesc");
    } else {
        q = session.getNamedQuery("getRepositoryItemsByCharPublicationDateOrderAsc");
    }
    q.setLong("repositoryId", repositoryId);
    q.setCharacter("firstChar", Character.toLowerCase(firstChar));
    q.setFirstResult(rowStart);
    q.setMaxResults(maxResults);
    q.setFetchSize(maxResults);
    return q.list();
}