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();
}
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();
}
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();
}
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();
}
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;
}
Aggregations