List of usage examples for org.hibernate Criteria setFirstResult
public Criteria setFirstResult(int firstResult);
From source file:com.inet.mail.business.base.BaseMailBusinessBean.java
License:Open Source License
/** * Search and result the list of entity that match the given criteria. * /*from www . j a va2s . c o m*/ * @param search T - the given criteria. * @param startAt int - the given start item position. * @param maxItem int - the given max items. * @return List<T> - list of entity. * @throws EjbException */ @SuppressWarnings("unchecked") @TransactionAttribute(value = TransactionAttributeType.SUPPORTS) public List<T> query(T search, int startAt, int maxItems) throws EJBException { // create criteria. Criteria criteria = buildQuery(search); // set start item position. criteria.setFirstResult(startAt); // set the expected max items. criteria.setMaxResults(maxItems); return criteria.list(); }
From source file:com.inet.mail.business.sr.MailHeaderSLBean.java
License:Open Source License
/** * {@inheritDoc}/* w ww.j ava 2 s. c o m*/ * * @see com.inet.mail.business.sr.MailHeaderBase#search(com.inet.mail.data.SearchResultDTO) */ @TransactionAttribute(TransactionAttributeType.SUPPORTS) public SearchResultDTO<MailHeader> search(SearchResultDTO<MailHeader> criteria) throws EJBException { // create the criteria. Criteria query = this.buildQuery(criteria.getCriteria()); // the total result. int totalResult = criteria.getTotalResult(); if (criteria.isCount()) { totalResult = count(criteria.getCriteria()); } // set result information. query.setFirstResult(criteria.getStartPos()); query.setMaxResults(criteria.getMaxResult()); // get list of result. List<MailHeader> result = query(query); // create result. return new SearchResultDTO<MailHeader>(result, criteria.getStartPos(), criteria.getMaxResult(), totalResult); }
From source file:com.inet.mail.business.sr.MailHeaderSLBean.java
License:Open Source License
/** * {@inheritDoc}/*from ww w .j a v a 2s. c om*/ * * @see com.inet.mail.business.sr.MailHeaderBase#search(java.lang.String, int, int) */ @TransactionAttribute(TransactionAttributeType.SUPPORTS) public SearchResultDTO<MailHeader> search(String criteria, int startAt, int maxItem) throws EJBException { // create the criteria. Criteria query = buildQuery(criteria); // get the total. int totalResult = count(criteria); // set result information. query.setFirstResult(startAt); query.setMaxResults(maxItem); // query data. List<MailHeader> result = query(query); // create result. return new SearchResultDTO<MailHeader>(result, startAt, maxItem, totalResult); }
From source file:com.inkubator.datacore.dao.impl.IDAOImpl.java
/** * Get All data for specific Entity (T). Note this method only return data * that have primary key, page able, and Sorting * * @param firstResult is int type and begin from 0 * @param maxResults is int type//from w w w . j a v a 2s .co m * @param order * @return List of entity */ public List<T> getAllDataPageAble(int firstResult, int maxResults, Order order) { Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); criteria.addOrder(order); criteria.add(Restrictions.isNotNull("id")); criteria.setFirstResult(firstResult); criteria.setMaxResults(maxResults); return (List<T>) criteria.list(); }
From source file:com.inkubator.datacore.dao.impl.IDAOImpl.java
/** * Get All data for specific Entity (T). Note this method only return data * that have primary key, page able, Sorting, and isActive condition * * @param firstResult is int type and begin from 0 * @param maxResults is int type//from w ww .j a va 2s. com * @param order is Hibernate Order * @param isActive is Boolean condition true or false * @return List of entity */ public List<T> getAllDataPageAbleIsActive(int firstResult, int maxResults, Order order, Boolean isActive) { Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); criteria.addOrder(order); criteria.add(Restrictions.isNotNull("id")); cekIsActive(criteria, isActive); criteria.setFirstResult(firstResult); criteria.setMaxResults(maxResults); return (List<T>) criteria.list(); }
From source file:com.inkubator.datacore.dao.impl.IDAOImpl.java
/** * Get All data for specific Entity (T). Note this method only return data * that have primary key, page able, Sorting, and isActive condition * * @param firstResult is int type and begin from 0 * @param maxResults is int type// w w w . j ava 2 s.co m * @param order is Hibernate Order * @param isActive is Integer condition 0 or 1 * @return List of entity */ public List<T> getAllDataPageAbleIsActive(int firstResult, int maxResults, Order order, Integer isActive) { Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); criteria.addOrder(order); criteria.add(Restrictions.isNotNull("id")); cekIsActive(criteria, isActive); criteria.setFirstResult(firstResult); criteria.setMaxResults(maxResults); return (List<T>) criteria.list(); }
From source file:com.inkubator.datacore.dao.impl.IDAOImpl.java
/** * Get All data for specific Entity (T). Note this method only return data * that have primary key, page able, Sorting, and isActive condition * * @param firstResult is int type and begin from 0 * @param maxResults is int type/*from www .j ava2 s. com*/ * @param order is Hibernate Order * @param isActive is Byte condition -127 or 127 * @return List of entity */ public List<T> getAllDataPageAbleIsActive(int firstResult, int maxResults, Order order, Byte isActive) { Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); criteria.addOrder(order); criteria.add(Restrictions.isNotNull("id")); cekIsActive(criteria, isActive); criteria.setFirstResult(firstResult); criteria.setMaxResults(maxResults); return (List<T>) criteria.list(); }
From source file:com.inkubator.hrm.dao.impl.ApprovalDefinitionDaoImpl.java
@Override public List<ApprovalDefinition> getByParam(ApprovalDefinitionSearchParameter searchParameter, int firstResult, int maxResults, Order order) { Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); doSearchApprovalDefinitionByParam(searchParameter, criteria); criteria.addOrder(order);//from w ww . j a v a2 s . c o m criteria.setFirstResult(firstResult); criteria.setMaxResults(maxResults); return criteria.list(); }
From source file:com.inkubator.hrm.dao.impl.AttendanceStatusDaoImpl.java
@Override public List<AttendanceStatus> getByParam(AttendanceStatusSearchParamater searchParameter, int firstResult, int maxResults, Order order) { Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); doSearchAttendanceStatusByParam(searchParameter, criteria); criteria.addOrder(order);/* w w w . j a va 2 s . co m*/ criteria.setFirstResult(firstResult); criteria.setMaxResults(maxResults); return criteria.list(); }
From source file:com.inkubator.hrm.dao.impl.BankGroupDaoImpl.java
@Override public List<BankGroup> getByParam(BankGroupSearchParameter searchParameter, int firstResult, int maxResults, Order order) {/*w ww . j ava 2 s .com*/ Criteria criteria = getCurrentSession().createCriteria(getEntityClass()); doSearchByParam(searchParameter, criteria); criteria.addOrder(order); criteria.setFirstResult(firstResult); criteria.setMaxResults(maxResults); return criteria.list(); }