Search in sources :

Example 66 with Criteria

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

the class HibernatePeriodStore method getPeriodsByPeriodType.

@Override
@SuppressWarnings("unchecked")
public List<Period> getPeriodsByPeriodType(PeriodType periodType) {
    Criteria criteria = getCriteria();
    criteria.add(Restrictions.eq("periodType", reloadPeriodType(periodType)));
    return criteria.list();
}
Also used : Criteria(org.hibernate.Criteria)

Example 67 with Criteria

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

the class HibernateProgramStageInstanceStore method get.

@Override
@SuppressWarnings("unchecked")
public List<ProgramStageInstance> get(TrackedEntityInstance entityInstance, EventStatus status) {
    Criteria criteria = getCriteria();
    criteria.createAlias("programInstance", "programInstance");
    criteria.add(Restrictions.eq("programInstance.entityInstance", entityInstance));
    criteria.add(Restrictions.eq("status", status));
    return criteria.list();
}
Also used : Criteria(org.hibernate.Criteria) DetachedCriteria(org.hibernate.criterion.DetachedCriteria)

Example 68 with Criteria

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

the class HibernateProgramStore method get.

@SuppressWarnings("unchecked")
@Override
public List<Program> get(ProgramType type, OrganisationUnit organisationUnit) {
    Criteria criteria1 = getCriteria();
    criteria1.createAlias("organisationUnits", "orgunit");
    criteria1.add(Restrictions.eq("programType", type));
    criteria1.add(Restrictions.eq("orgunit.id", organisationUnit.getId()));
    return criteria1.list();
}
Also used : Criteria(org.hibernate.Criteria)

Example 69 with Criteria

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

the class HibernatePeriodStore method getIntersectingPeriodsByPeriodType.

@Override
@SuppressWarnings("unchecked")
public List<Period> getIntersectingPeriodsByPeriodType(PeriodType periodType, Date startDate, Date endDate) {
    Criteria criteria = getCriteria();
    criteria.add(Restrictions.eq("periodType", reloadPeriodType(periodType)));
    criteria.add(Restrictions.ge("endDate", startDate));
    criteria.add(Restrictions.le("startDate", endDate));
    return criteria.list();
}
Also used : Criteria(org.hibernate.Criteria)

Example 70 with Criteria

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

the class HibernatePeriodStore method getPeriodsBetweenDates.

@Override
@SuppressWarnings("unchecked")
public List<Period> getPeriodsBetweenDates(Date startDate, Date endDate) {
    Criteria criteria = getCriteria();
    criteria.add(Restrictions.ge("startDate", startDate));
    criteria.add(Restrictions.le("endDate", endDate));
    criteria.setCacheable(true);
    return criteria.list();
}
Also used : 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