List of usage examples for org.hibernate Criteria uniqueResult
public Object uniqueResult() throws HibernateException;
From source file:au.org.theark.lims.model.dao.BiospecimenDao.java
License:Open Source License
public Biospecimen getBiospecimen(Long id) throws EntityNotFoundException { Criteria criteria = getSession().createCriteria(Biospecimen.class); criteria.add(Restrictions.eq("id", id)); Biospecimen biospecimen = (Biospecimen) criteria.uniqueResult(); if (biospecimen.getId() == null) { throw new EntityNotFoundException("The entity with id" + id.toString() + " cannot be found."); }/* ww w . j av a 2s. com*/ return biospecimen; }
From source file:au.org.theark.lims.model.dao.BiospecimenDao.java
License:Open Source License
public long getBiospecimenCount(Biospecimen biospecimenCriteria) { // Handle for study not in context if (biospecimenCriteria.getStudy() == null) { return 0; }/*from w w w . ja v a2s . c o m*/ Criteria criteria = buildBiospecimenCriteria(biospecimenCriteria); criteria.setProjection(Projections.rowCount()); Long totalCount = (Long) criteria.uniqueResult(); return totalCount.intValue(); }
From source file:au.org.theark.lims.model.dao.BiospecimenDao.java
License:Open Source License
public long getBiospecimenCount(LimsVO limsVo) { Criteria criteria = buildBiospecimenCriteria(limsVo); criteria.setProjection(Projections.rowCount()); Long totalCount = (Long) criteria.uniqueResult(); return totalCount.intValue(); }
From source file:au.org.theark.lims.model.dao.BiospecimenDao.java
License:Open Source License
public long getBiospecimenCustomFieldDataCount(Biospecimen biospecimenCriteria, ArkFunction arkFunction) { Criteria criteria = getSession().createCriteria(CustomFieldDisplay.class); criteria.createAlias("customField", "cfield"); // Allow child studies to inherit parent defined custom fields List studyList = new ArrayList(); studyList.add(biospecimenCriteria.getStudy()); if (biospecimenCriteria.getStudy().getParentStudy() != null && biospecimenCriteria.getStudy().getParentStudy() != biospecimenCriteria.getStudy()) { studyList.add(biospecimenCriteria.getStudy().getParentStudy()); }// www. j av a 2 s .c o m criteria.add(Restrictions.in("cfield.study", studyList)); criteria.add(Restrictions.eq("cfield.arkFunction", arkFunction)); criteria.setProjection(Projections.rowCount()); return (Long) criteria.uniqueResult(); }
From source file:au.org.theark.lims.model.dao.BiospecimenDao.java
License:Open Source License
public Double getQuantityAvailable(Biospecimen biospecimen) { Criteria criteria = getSession().createCriteria(BioTransaction.class); criteria.add(Restrictions.eq("biospecimen", biospecimen)); criteria.setProjection(Projections.sum("quantity")); Double sum = (Double) criteria.uniqueResult(); return sum;/*from w w w . j a v a 2s . c o m*/ }
From source file:au.org.theark.lims.model.dao.BiospecimenDao.java
License:Open Source License
public BiospecimenUidTemplate getBiospecimenUidTemplate(Study study) { Criteria criteria = getSession().createCriteria(BiospecimenUidTemplate.class); criteria.add(Restrictions.eq("study", study)); BiospecimenUidTemplate biospecimenUidTemplate = (BiospecimenUidTemplate) criteria.uniqueResult(); return biospecimenUidTemplate; }
From source file:au.org.theark.lims.model.dao.BiospecimenDao.java
License:Open Source License
protected BiospecimenUidSequence getBiospecimenUidSequence(Study study) { // Stateless sessions should be used to avoid locking the record for future update // by getSession(), which relies on the "open session filter" mechanism StatelessSession session = getStatelessSession(); Criteria criteria = session.createCriteria(BiospecimenUidSequence.class); criteria.add(Restrictions.eq(Constants.SUBJECTUIDSEQ_STUDYNAMEID, study.getName())); criteria.setMaxResults(1);//from w ww.j ava 2 s. c om BiospecimenUidSequence result = (BiospecimenUidSequence) criteria.uniqueResult(); session.close(); return result; }
From source file:au.org.theark.lims.model.dao.BiospecimenDao.java
License:Open Source License
public boolean studyHasBiospecimens(Study study) { Criteria criteria = getSession().createCriteria(Biospecimen.class); criteria.add(Restrictions.eq("study", study)); criteria.setProjection(Projections.count("id")); Long count = (Long) criteria.uniqueResult(); return count > 0; }
From source file:au.org.theark.lims.model.dao.BiospecimenDao.java
License:Open Source License
public BioSampletype getBioSampleTypeByName(String name) { Criteria criteria = getSession().createCriteria(BioSampletype.class); criteria.add(Restrictions.eq("name", name)); return (BioSampletype) criteria.uniqueResult(); }
From source file:au.org.theark.lims.model.dao.BiospecimenDao.java
License:Open Source License
public TreatmentType getTreatmentTypeByName(String name) { Criteria criteria = getSession().createCriteria(TreatmentType.class); criteria.add(Restrictions.eq("name", name)); return (TreatmentType) criteria.uniqueResult(); }