Search in sources :

Example 76 with Criteria

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

the class HibernateIdentifiableObjectStore method getByUniqueAttributeValue.

@Override
@SuppressWarnings("unchecked")
public T getByUniqueAttributeValue(Attribute attribute, String value) {
    if (attribute == null || StringUtils.isEmpty(value) || !attribute.isUnique()) {
        return null;
    }
    Criteria criteria = getSharingCriteria();
    criteria.createAlias("attributeValues", "av");
    criteria.add(Restrictions.eq("av.value", value));
    return (T) criteria.uniqueResult();
}
Also used : Criteria(org.hibernate.Criteria)

Example 77 with Criteria

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

the class HibernateOutboundSmsStore method get.

@SuppressWarnings("unchecked")
@Override
public List<OutboundSms> get(OutboundSmsStatus status) {
    Session session = sessionFactory.getCurrentSession();
    Criteria criteria = session.createCriteria(OutboundSms.class).addOrder(Order.desc("date"));
    if (status != null) {
        criteria.add(Restrictions.eq("status", status));
    }
    return criteria.list();
}
Also used : OutboundSms(org.hisp.dhis.sms.outbound.OutboundSms) Criteria(org.hibernate.Criteria) Session(org.hibernate.Session)

Example 78 with Criteria

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

the class HibernateOutboundSmsStore method get.

@SuppressWarnings("unchecked")
@Override
public List<OutboundSms> get(OutboundSmsStatus status, Integer min, Integer max) {
    Session session = sessionFactory.getCurrentSession();
    Criteria criteria = session.createCriteria(OutboundSms.class).addOrder(Order.desc("date"));
    if (status != null) {
        criteria.add(Restrictions.eq("status", status));
    }
    if (min != null && max != null) {
        criteria.setFirstResult(min).setMaxResults(max);
    }
    return criteria.list();
}
Also used : OutboundSms(org.hisp.dhis.sms.outbound.OutboundSms) Criteria(org.hibernate.Criteria) Session(org.hibernate.Session)

Example 79 with Criteria

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

the class HibernateSMSCommandStore method getSMSCommands.

@SuppressWarnings("unchecked")
@Override
public List<SMSCommand> getSMSCommands() {
    Criteria criteria = sessionFactory.getCurrentSession().createCriteria(SMSCommand.class);
    criteria.addOrder(Order.asc("name"));
    return criteria.list();
}
Also used : Criteria(org.hibernate.Criteria)

Example 80 with Criteria

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

the class HibernateSMSCommandStore method getSMSCommand.

@Override
public SMSCommand getSMSCommand(String commandName, ParserType parserType) {
    Criteria criteria = sessionFactory.getCurrentSession().createCriteria(SMSCommand.class);
    criteria.add(Restrictions.eq("parserType", parserType));
    criteria.add(Restrictions.ilike("name", "%" + commandName + "%"));
    if (criteria.list() != null && criteria.list().size() > 0) {
        return (SMSCommand) criteria.list().get(0);
    }
    return null;
}
Also used : SMSCommand(org.hisp.dhis.sms.command.SMSCommand) 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