Example usage for org.hibernate Criteria list

List of usage examples for org.hibernate Criteria list

Introduction

In this page you can find the example usage for org.hibernate Criteria list.

Prototype

public List list() throws HibernateException;

Source Link

Document

Get the results.

Usage

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);//w  ww .  j  a v  a2s  .  com
    criteria.setMaxResults(count);
    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:au.org.theark.study.model.dao.StudyDao.java

License:Open Source License

@Override
public void saveOrUpdate(StudyCalendarVo studyCalendarVo) {
    StudyCalendar calendar = studyCalendarVo.getStudyCalendar();
    saveOrUpdate(calendar);// w  ww.ja v a  2  s .  c  o m

    Criteria criteria = getSession().createCriteria(LinkCalendarCustomField.class);
    criteria.add(Restrictions.eq("studyCalendar", calendar));
    List<LinkCalendarCustomField> searchResults = criteria.list();
    for (LinkCalendarCustomField calendarCustomFields : searchResults) {
        deleteCalendarCustomField(calendarCustomFields);
    }

    for (CustomField customField : studyCalendarVo.getSelectedCustomFields()) {
        LinkCalendarCustomField linkCalendarCustomField = new LinkCalendarCustomField();
        linkCalendarCustomField.setStudyCalendar(calendar);
        linkCalendarCustomField.setCustomField(customField);
        saveCalendarCustomField(linkCalendarCustomField);
    }
}

From source file:au.org.theark.study.model.dao.StudyDao.java

License:Open Source License

public List<StudyCalendar> searchStudyCalenderList(StudyCalendar studyCalendar) {
    List<StudyCalendar> list = new ArrayList<StudyCalendar>();
    Criteria criteria = getSession().createCriteria(StudyCalendar.class);

    criteria.add(Restrictions.eq("study", studyCalendar.getStudy()));

    if (studyCalendar.getName() != null) {
        criteria.add(Restrictions.ilike("name", studyCalendar.getName(), MatchMode.ANYWHERE));
    }//  w  w w  .  j  a v  a  2 s  . c o  m

    if (studyCalendar.getStartDate() != null) {
        criteria.add(Restrictions.ge("startDate", studyCalendar.getStartDate()));
    }

    if (studyCalendar.getEndDate() != null) {
        criteria.add(Restrictions.le("endDate", studyCalendar.getEndDate()));
    }

    criteria.setFetchMode("studyComp", FetchMode.JOIN);

    list = criteria.list();

    return list;
}

From source file:au.org.theark.study.model.dao.StudyDao.java

License:Open Source License

public List<CustomField> getStudySubjectCustomFieldList(Long studyId) {
    List<CustomField> list = new ArrayList<CustomField>();
    Criteria criteria = getSession().createCriteria(CustomField.class);
    criteria.createAlias("study", "st", JoinType.LEFT_OUTER_JOIN);
    criteria.createAlias("customFieldType", "cft", JoinType.LEFT_OUTER_JOIN);
    criteria.add(Restrictions.eq("st.id", studyId));
    criteria.add(Restrictions.eq("cft.name", au.org.theark.core.Constants.SUBJECT));
    list = criteria.list();
    return list;//from www .  j  a  va  2 s  .co  m
}

From source file:au.org.theark.study.model.dao.StudyDao.java

License:Open Source License

public List<CustomField> getSelectedCalendarCustomFieldList(StudyCalendar studyCalendar) {
    List<CustomField> list = new ArrayList<CustomField>();
    Criteria criteria = getSession().createCriteria(CustomField.class);
    criteria.createAlias("linkCalendarCustomField", "lccf", JoinType.INNER_JOIN);
    criteria.createAlias("linkCalendarCustomField.studyCalendar", "sc", JoinType.INNER_JOIN);
    criteria.add(Restrictions.eq("sc.id", studyCalendar.getId()));
    list = criteria.list();
    return list;/*from w  ww.  ja  va  2 s.c  o  m*/
}

From source file:au.org.theark.study.model.dao.StudyDao.java

License:Open Source License

public boolean isStudyComponentBeingUsedInConsent(StudyComp studyComp) {
    Criteria criteria = getSession().createCriteria(Consent.class);
    criteria.add(Restrictions.eq("study", studyComp.getStudy()));
    criteria.add(Restrictions.eq("studyComp", studyComp));
    List<Consent> consents = criteria.list();
    return (consents.size() > 0);

}

From source file:Babysu.Dao.ClienteDao.java

public List<Cliente> consulta() {

    sessao = HibernateUtil.getSessionFactory().openSession();
    List<Cliente> clientes = new ArrayList<>();
    try {/*w w w.  j  av a2  s. c  o m*/
        trans = sessao.beginTransaction();
        Criteria c = sessao.createCriteria(Cliente.class);
        clientes = c.list();

    } catch (Exception e) {
        alerta.daoMsg(e);
    } finally {
        sessao.close();
    }
    return clientes;
}

From source file:Babysu.Dao.CompraBabysuDao.java

public List<CompraBabysu> consulta() {
    sessao = HibernateUtil.getSessionFactory().openSession();
    List<CompraBabysu> lista = new ArrayList<>();
    try {// ww  w  . j  a  v  a  2  s .c o  m
        trans = sessao.beginTransaction();
        Criteria c = sessao.createCriteria(CompraBabysu.class);
        lista = c.list();
    } catch (Exception e) {
        alerta.daoMsg(e);
    } finally {
        sessao.close();
    }

    return lista;
}

From source file:Babysu.Dao.CompraBabysuDao.java

public CompraBabysu consultaId(long id) {
    sessao = HibernateUtil.getSessionFactory().openSession();
    List<CompraBabysu> list = new ArrayList<>();
    CompraBabysu cb = new CompraBabysu();
    try {/*from   w  w  w.  j a v a 2s  . co m*/
        trans = sessao.beginTransaction();
        Criteria c = sessao.createCriteria(CompraBabysu.class);
        list = c.list();

        for (CompraBabysu compra : list) {
            if (compra.getId() == id) {
                cb = compra;
            }
        }

    } catch (Exception e) {
        alerta.daoMsg(e);
    } finally {
        sessao.close();
    }

    return cb;
}