List of usage examples for org.hibernate Criteria setFirstResult
public Criteria setFirstResult(int firstResult);
From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java
License:Open Source License
@Override public LinkPhenoDataSetCategoryField getSwapOverPhenoDataSetFieldForUpButton( LinkPhenoDataSetCategoryField linkPhenoDataSetCategoryField) { Criteria criteria = getSession().createCriteria(LinkPhenoDataSetCategoryField.class); criteria.add(Restrictions.eq("arkFunction", linkPhenoDataSetCategoryField.getArkFunction())); criteria.add(Restrictions.eq("study", linkPhenoDataSetCategoryField.getStudy())); criteria.add(Restrictions.eq("arkUser", linkPhenoDataSetCategoryField.getArkUser())); criteria.add(//from www. j a va 2 s . c o m Restrictions.eq("phenoDataSetCategory", linkPhenoDataSetCategoryField.getPhenoDataSetCategory())); criteria.add(Restrictions.lt("orderNumber", linkPhenoDataSetCategoryField.getOrderNumber())); criteria.addOrder(Order.desc("orderNumber")); criteria.setFirstResult(0); criteria.setMaxResults(1); List<LinkPhenoDataSetCategoryField> linkPhenoDataSetCategoryFields = (List<LinkPhenoDataSetCategoryField>) criteria .list(); if (linkPhenoDataSetCategoryFields.size() > 0) { return linkPhenoDataSetCategoryFields.get(0); } else { return null; } }
From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java
License:Open Source License
@Override public LinkPhenoDataSetCategoryField getSwapOverPhenoDataSetFieldForDownButton( LinkPhenoDataSetCategoryField linkPhenoDataSetCategoryField) { Criteria criteria = getSession().createCriteria(LinkPhenoDataSetCategoryField.class); criteria.add(Restrictions.eq("arkFunction", linkPhenoDataSetCategoryField.getArkFunction())); criteria.add(Restrictions.eq("study", linkPhenoDataSetCategoryField.getStudy())); criteria.add(Restrictions.eq("arkUser", linkPhenoDataSetCategoryField.getArkUser())); criteria.add(//from w w w . j ava 2s . c o m Restrictions.eq("phenoDataSetCategory", linkPhenoDataSetCategoryField.getPhenoDataSetCategory())); criteria.add(Restrictions.gt("orderNumber", linkPhenoDataSetCategoryField.getOrderNumber())); criteria.addOrder(Order.asc("orderNumber")); criteria.setFirstResult(0); criteria.setMaxResults(1); List<LinkPhenoDataSetCategoryField> linkPhenoDataSetCategoryFields = (List<LinkPhenoDataSetCategoryField>) criteria .list(); if (linkPhenoDataSetCategoryFields.size() > 0) { return linkPhenoDataSetCategoryFields.get(0); } else { return null; } }
From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java
License:Open Source License
public List<PhenoDataSetGroup> getPhenoDataSetFieldGroups(PhenoDataSetGroup phenoDataSetGroup, int first, int count) { Criteria criteria = buildGenericPhenoFieldGroupCriteria(phenoDataSetGroup); criteria.setFirstResult(first); criteria.setMaxResults(count);//from www. j a v a 2 s. co m List<PhenoDataSetGroup> list = (List<PhenoDataSetGroup>) criteria.list(); return list; }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
/** * Pageable person phone list./* www .j a v a2 s . c o m*/ */ public List<Phone> pageablePersonPhoneLst(Long personId, Phone phoneCriteria, int first, int count) { Criteria criteria = buildGeneralPhoneCriteria(personId, phoneCriteria); criteria.setFirstResult(first); criteria.setMaxResults(count); List<Phone> personPhoneList = criteria.list(); //log.info("Number of phones fetched " + personPhoneList.size() + " Person Id" + personId.intValue()); if (personPhoneList.isEmpty()) { // throw new EntityNotFoundException("The entity with id" + personId.toString() + " cannot be found."); log.info(" personId " + personId + " had no phones. No drama"); } return personPhoneList; }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public List<Address> pageablePersonAddressLst(Long personId, Address addressCriteria, int first, int count) { Criteria criteria = buildGeneralAddressCriteria(personId, addressCriteria); criteria.setFirstResult(first); criteria.setMaxResults(count);/* www .jav a 2s .c o m*/ List<Address> personAddressList = criteria.list(); //log.info("Number of phones fetched " + personPhoneList.size() + " Person Id" + personId.intValue()); if (personAddressList.isEmpty()) { // throw new EntityNotFoundException("The entity with id" + personId.toString() + " cannot be found."); log.info(" personId " + personId + " had no addresses. No drama"); } return personAddressList; }
From source file:be.redlab.examples.databasetesting.common.AbstractJpaDao.java
License:Apache License
protected List<T> findByCriteria(final int firstResult, final int maxResults, final Order order, final Criterion... criterion) { Session session = (Session) getEntityManager().getDelegate(); Criteria crit = session.createCriteria(getEntityClass()); for (final Criterion c : criterion) { crit.add(c);//from w w w . j a va 2 s . co m } if (order != null) { crit.addOrder(order); } if (firstResult > 0) { crit.setFirstResult(firstResult); } if (maxResults > 0) { crit.setMaxResults(maxResults); } return crit.list(); }
From source file:br.com.arsmachina.dao.hibernate.ReadableDAOImpl.java
License:Apache License
/** * If <code>sortingConstraints</code> is <code>null</code> or empty, this implementation * sort the results by the {@link SortCriterion}s returned by * {@link #getDefaultSortCriterions()}./*from w ww. j a v a2 s . c o m*/ * * @see br.com.arsmachina.dao.ReadableDAO#findAll(int, int, * br.com.arsmachina.dao.SortCriterion[]) */ @SuppressWarnings("unchecked") public List<T> findAll(int firstResult, int maximumResults, SortCriterion... sortingConstraints) { Criteria criteria = createCriteria(); criteria.setFirstResult(firstResult); criteria.setMaxResults(maximumResults); if (sortingConstraints == null || sortingConstraints.length == 0) { sortingConstraints = getDefaultSortCriteria(); } addSortCriteria(criteria, sortingConstraints); return criteria.list(); }
From source file:br.com.arsmachina.dao.hibernate.ReadableDAOImpl.java
License:Apache License
/** * Creates a {@link Criteria} for this entity class with given sort criteria, * first result index and maximum number of results. * /* w w w . jav a 2s . co m*/ * @return a {@link Criteria}. */ public Criteria createCriteria(int firstIndex, int maximumResults, SortCriterion... sortCriteria) { Criteria criteria = createCriteria(sortCriteria); criteria.setFirstResult(firstIndex); criteria.setMaxResults(maximumResults); return criteria; }
From source file:br.com.ateliens.repository.ClientesFiltrados.java
@SuppressWarnings("unchecked") public List<Cliente> filtrados(FiltroCliente filtro) { Criteria criteria = criarCriteriaParaFiltro(filtro); criteria.setFirstResult(filtro.getPrimeiroRegistro()); criteria.setMaxResults(filtro.getQuantidadeRegistros()); if (filtro.isAscendente() && filtro.getPropriedadeOrdenacao() != null) { criteria.addOrder(Order.asc(filtro.getPropriedadeOrdenacao())); } else if (filtro.getPropriedadeOrdenacao() != null) { criteria.addOrder(Order.desc(filtro.getPropriedadeOrdenacao())); }//from w w w . j a v a 2 s .co m return criteria.list(); }
From source file:br.com.gartech.nfse.integrador.dao.GenericDAOImpl.java
@SuppressWarnings("unchecked") public List<T> findByExample(T entity, int firstResult, int maxResults) { Session session = getSession();//from ww w . ja v a 2 s . c o m log.debug("findByExample on " + getEntityClass()); Criteria criteria = session.createCriteria(getEntityClass()).add(Example.create(entity)); criteria.setFirstResult(firstResult); if (maxResults > 0) { criteria.setMaxResults(maxResults); criteria.addOrder(Order.asc("dataRecebimento")); } log.debug("findByExample result " + criteria.list().size()); return (List<T>) criteria.list(); }