Search in sources :

Example 61 with Criteria

use of org.hibernate.Criteria in project dhis2-core by dhis2.

the class HibernateSectionStore method getSectionByName.

@Override
public Section getSectionByName(String name, DataSet dataSet) {
    Criteria criteria = getCriteria();
    criteria.add(Restrictions.eq("name", name));
    criteria.add(Restrictions.eq("dataSet", dataSet));
    return (Section) criteria.uniqueResult();
}
Also used : Criteria(org.hibernate.Criteria) Section(org.hisp.dhis.dataset.Section)

Example 62 with Criteria

use of org.hibernate.Criteria in project dhis2-core by dhis2.

the class HibernateDataValueAuditStore method getDataValueAudits.

@Override
@SuppressWarnings("unchecked")
public List<DataValueAudit> getDataValueAudits(List<DataElement> dataElements, List<Period> periods, List<OrganisationUnit> organisationUnits, DataElementCategoryOptionCombo categoryOptionCombo, DataElementCategoryOptionCombo attributeOptionCombo, AuditType auditType, int first, int max) {
    Criteria criteria = getDataValueAuditCriteria(dataElements, periods, organisationUnits, categoryOptionCombo, attributeOptionCombo, auditType);
    criteria.addOrder(Order.desc("created"));
    criteria.setFirstResult(first);
    criteria.setMaxResults(max);
    return criteria.list();
}
Also used : Criteria(org.hibernate.Criteria)

Example 63 with Criteria

use of org.hibernate.Criteria in project dhis2-core by dhis2.

the class HibernateLockExceptionStore method getAllOrderedName.

@Override
@SuppressWarnings("unchecked")
public List<LockException> getAllOrderedName(int first, int max) {
    Criteria criteria = getCriteria();
    criteria.setFirstResult(first);
    criteria.setMaxResults(max);
    return criteria.list();
}
Also used : Criteria(org.hibernate.Criteria)

Example 64 with Criteria

use of org.hibernate.Criteria in project dhis2-core by dhis2.

the class HibernatePeriodStore method getPeriodType.

@Override
public PeriodType getPeriodType(Class<? extends PeriodType> periodType) {
    Session session = sessionFactory.getCurrentSession();
    Criteria criteria = session.createCriteria(periodType);
    return (PeriodType) criteria.setCacheable(true).uniqueResult();
}
Also used : PeriodType(org.hisp.dhis.period.PeriodType) Criteria(org.hibernate.Criteria) Session(org.hibernate.Session)

Example 65 with Criteria

use of org.hibernate.Criteria in project dhis2-core by dhis2.

the class HibernatePeriodStore method getPeriod.

@Override
public Period getPeriod(Date startDate, Date endDate, PeriodType periodType) {
    Criteria criteria = getCriteria();
    criteria.add(Restrictions.eq("startDate", startDate));
    criteria.add(Restrictions.eq("endDate", endDate));
    criteria.add(Restrictions.eq("periodType", reloadPeriodType(periodType)));
    return (Period) criteria.uniqueResult();
}
Also used : Period(org.hisp.dhis.period.Period) Criteria(org.hibernate.Criteria)

Aggregations

Criteria (org.hibernate.Criteria)180 Session (org.hibernate.Session)95 Test (org.junit.Test)69 List (java.util.List)39 Transaction (org.hibernate.Transaction)39 DetachedCriteria (org.hibernate.criterion.DetachedCriteria)27 ArrayList (java.util.ArrayList)15 TestForIssue (org.hibernate.testing.TestForIssue)12 Iterator (java.util.Iterator)9 Period (org.hisp.dhis.period.Period)8 Map (java.util.Map)6 State (org.hibernate.test.cache.infinispan.functional.entities.State)5 OnmsCriteria (org.opennms.netmgt.model.OnmsCriteria)5 HibernateCallback (org.springframework.orm.hibernate3.HibernateCallback)5 HashSet (java.util.HashSet)3 Criterion (org.hibernate.criterion.Criterion)3 Statistics (org.hibernate.stat.Statistics)3 Pager (org.hisp.dhis.common.Pager)3 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)2 HashMap (java.util.HashMap)2