List of usage examples for org.hibernate Query setFetchSize
Query<R> setFetchSize(int fetchSize);
From source file:edu.ur.hibernate.ir.item.db.HbSponsorDAO.java
License:Apache License
/** * /*from w w w.ja v a 2 s .co m*/ * @see edu.ur.ir.item.SponsorDAO#getCollectionSponsorsBetweenChar(int, int, edu.ur.ir.institution.InstitutionalCollection, char, char, edu.ur.order.OrderType) */ @SuppressWarnings("unchecked") public List<Sponsor> getCollectionSponsorsBetweenChar(final int rowStart, final int maxResults, final InstitutionalCollection collection, 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.DESCENDING_ORDER)) { q = session.getNamedQuery("getCollectionSponsorNameByCharRangeOrderDesc"); } else { q = session.getNamedQuery("getCollectionSponsorNameByCharRangeOrderAsc"); } q.setLong(0, collection.getLeftValue()); q.setLong(1, collection.getRightValue()); q.setLong(2, collection.getTreeRoot().getId()); q.setCharacter(3, Character.toLowerCase(firstChar)); q.setCharacter(4, Character.toLowerCase(lastChar)); q.setFirstResult(rowStart); q.setMaxResults(maxResults); q.setFetchSize(maxResults); return q.list(); } }); return sponsors; }
From source file:edu.ur.hibernate.ir.item.db.HbSponsorDAO.java
License:Apache License
/** * @see edu.ur.ir.item.SponsorDAO#getCollectionSponsorsByChar(int, int, edu.ur.ir.institution.InstitutionalCollection, char, edu.ur.order.OrderType) *///from w w w.ja v a2s . c om @SuppressWarnings("unchecked") public List<Sponsor> getCollectionSponsorsByChar(final int rowStart, final int maxResults, final InstitutionalCollection collection, 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.DESCENDING_ORDER)) { q = session.getNamedQuery("getCollectionSponsorNameByCharOrderDesc"); } else { q = session.getNamedQuery("getCollectionSponsorNameByCharOrderAsc"); } q.setLong(0, collection.getLeftValue()); q.setLong(1, collection.getRightValue()); q.setLong(2, collection.getTreeRoot().getId()); q.setCharacter(3, Character.toLowerCase(firstChar)); q.setFirstResult(rowStart); q.setMaxResults(maxResults); q.setFetchSize(maxResults); return q.list(); } }); return sponsors; }
From source file:edu.ur.hibernate.ir.item.db.HbSponsorDAO.java
License:Apache License
/** * /*from w w w. j a v a 2s .c om*/ * @see edu.ur.ir.item.SponsorDAO#getCollectionSponsorsByName(int, int, edu.ur.ir.institution.InstitutionalCollection, edu.ur.order.OrderType) */ @SuppressWarnings("unchecked") public List<Sponsor> getCollectionSponsorsByName(final int rowStart, final int maxResults, final InstitutionalCollection collection, 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.DESCENDING_ORDER)) { q = session.getNamedQuery("getCollectionSponsorNameByNameOrderDesc"); } else { q = session.getNamedQuery("getCollectionSponsorNameByNameOrderAsc"); } q.setLong(0, collection.getLeftValue()); q.setLong(1, collection.getRightValue()); q.setLong(2, collection.getTreeRoot().getId()); q.setFirstResult(rowStart); q.setMaxResults(maxResults); q.setFetchSize(maxResults); return q.list(); } }); return sponsors; }
From source file:edu.ur.hibernate.ir.news.db.HbNewsDAO.java
License:Apache License
/** * Get the availabe news items.//from w w w.ja v a2s . co m * * @param d - date the news items should be available * @param offset - where to start in the list * @param numToFetch - maximum number of items to fetch * @return- available news items */ @SuppressWarnings("unchecked") public List<NewsItem> getAvailableNewsItems(final Date d, final int offset, final int numToFetch) { return (List<NewsItem>) hbCrudDAO.getHibernateTemplate().executeFind(new HibernateCallback() { public Object doInHibernate(Session session) { Query query = session.getNamedQuery("getAvailableNewsItemsForDate"); query.setParameter(0, d); query.setParameter(1, d); query.setFirstResult(offset); query.setMaxResults(numToFetch); query.setFetchSize(numToFetch); return query.list(); } }); }
From source file:edu.ur.hibernate.ir.news.db.HbNewsDAO.java
License:Apache License
@SuppressWarnings("unchecked") public List<NewsItem> getNewsItems(final int rowStart, final int numberOfResultsToShow, final String sortType) { List<NewsItem> newsItems = (List<NewsItem>) hbCrudDAO.getHibernateTemplate() .execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Query q = null; if (sortType.equalsIgnoreCase("asc")) { q = session.getNamedQuery("getNewsItemsOrderByNameAsc"); } else { q = session.getNamedQuery("getNewsItemsOrderByNameDesc"); }/* www . j a v a 2 s. c o m*/ q.setFirstResult(rowStart); q.setMaxResults(numberOfResultsToShow); q.setReadOnly(true); q.setFetchSize(numberOfResultsToShow); return q.list(); } }); return newsItems; }
From source file:edu.ur.hibernate.ir.person.db.HbContributorTypeDAO.java
License:Apache License
@SuppressWarnings("unchecked") public List<ContributorType> getContributorTypes(final int rowStart, final int numberOfResultsToShow, final String sortType) { List<ContributorType> contributorTypes = (List<ContributorType>) hbCrudDAO.getHibernateTemplate() .execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Query q = null; if (sortType.equalsIgnoreCase("asc")) { q = session.getNamedQuery("getContributorTypesOrderByNameAsc"); } else { q = session.getNamedQuery("getContributorTypesOrderByNameDesc"); }//from w w w. j av a 2 s. c om q.setFirstResult(rowStart); q.setMaxResults(numberOfResultsToShow); q.setReadOnly(true); q.setFetchSize(numberOfResultsToShow); return q.list(); } }); return contributorTypes; }
From source file:edu.ur.hibernate.ir.person.db.HbPersonNameDAO.java
License:Apache License
/** * Returns all people with a first name like the specified value. * /* ww w . j a va2s .c o m*/ * @param firstName * @param startRecord * @param numRecords */ @SuppressWarnings("unchecked") public List<PersonName> findPersonLikeFirstName(String firstName, final int startRecord, final int numRecords) { final String qFirstName = firstName + '%'; //return getByQuery("findPersonLikeFirstName", startRecord, numRecords); return (List<PersonName>) hbCrudDAO.getHibernateTemplate().executeFind(new HibernateCallback() { public Object doInHibernate(Session session) { Query query = session.getNamedQuery("findPersonLikeFirstName"); query.setFirstResult(startRecord); query.setMaxResults(numRecords); query.setString(0, qFirstName); query.setFetchSize(numRecords); return query.list(); } }); }
From source file:edu.ur.hibernate.ir.person.db.HbPersonNameDAO.java
License:Apache License
/** * Finds all people with a last name like the specified last name. * //from w w w . j av a 2s .c om * @param lastName * @param startRecord * @param numRecords */ @SuppressWarnings("unchecked") public List<PersonName> findPersonLikeLastName(String lastName, final int startRecord, final int numRecords) { final String qLastName = lastName + '%'; //return getByQuery("findPersonLikeFirstName", startRecord, numRecords); return (List<PersonName>) hbCrudDAO.getHibernateTemplate().executeFind(new HibernateCallback() { public Object doInHibernate(Session session) { Query query = session.getNamedQuery("findPersonLikeLastName"); query.setFirstResult(startRecord); query.setMaxResults(numRecords); query.setString(0, qLastName); query.setFetchSize(numRecords); return query.list(); } }); }
From source file:edu.ur.hibernate.ir.person.db.HbPersonNameDAO.java
License:Apache License
/** * Finds all people with the specified first and last name. * /*w ww . j a va 2 s . co m*/ * @param firstName * @param lastName * @param startRecord * @param numRecords */ @SuppressWarnings("unchecked") public List<PersonName> findPersonLikeFirstLastName(String firstName, String lastName, final int startRecord, final int numRecords) { final String qLastName = lastName + '%'; final String qFirstName = firstName + '%'; //return getByQuery("findPersonLikeFirstName", startRecord, numRecords); return (List<PersonName>) hbCrudDAO.getHibernateTemplate().executeFind(new HibernateCallback() { public Object doInHibernate(Session session) { Query query = session.getNamedQuery("findPersonLikeFirstLastName"); query.setFirstResult(startRecord); query.setMaxResults(numRecords); query.setString(0, qLastName); query.setString(1, qFirstName); query.setFetchSize(numRecords); return query.list(); } }); }
From source file:edu.ur.hibernate.ir.person.db.HbPersonNameDAO.java
License:Apache License
/** * @see edu.ur.ir.person.PersonNameDAO#getCollectionPersonNamesBetweenChar(int, int, edu.ur.ir.institution.InstitutionalCollection, char, char, edu.ur.order.OrderType) *//*from ww w. j av a 2s . c o m*/ @SuppressWarnings("unchecked") public List<PersonName> getCollectionPersonNamesBetweenChar(final int rowStart, final int maxResults, final InstitutionalCollection collection, final char firstChar, final char lastChar, final OrderType orderType) { List<PersonName> personNames = (List<PersonName>) hbCrudDAO.getHibernateTemplate() .execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Query q = null; if (orderType.equals(OrderType.DESCENDING_ORDER)) { q = session.getNamedQuery("getCollectionPersonNameByCharRangeOrderDesc"); } else { q = session.getNamedQuery("getCollectionPersonNameByCharRangeOrderAsc"); } q.setLong(0, collection.getLeftValue()); q.setLong(1, collection.getRightValue()); q.setLong(2, collection.getTreeRoot().getId()); q.setCharacter(3, Character.toLowerCase(firstChar)); q.setCharacter(4, Character.toLowerCase(lastChar)); q.setFirstResult(rowStart); q.setMaxResults(maxResults); q.setFetchSize(maxResults); return q.list(); } }); return personNames; }