Example usage for org.hibernate.criterion Restrictions isNotNull

List of usage examples for org.hibernate.criterion Restrictions isNotNull

Introduction

In this page you can find the example usage for org.hibernate.criterion Restrictions isNotNull.

Prototype

public static Criterion isNotNull(String propertyName) 

Source Link

Document

Apply an "is not null" constraint to the named property

Usage

From source file:org.LexGrid.LexBIG.caCore.dao.orm.translators.GridCQLToDetachedCriteria.java

License:Open Source License

private Criterion processAttribute(Attribute att, String parentAlias) {
    String attName = null;//  w  w w  .  ja  va 2 s .  co  m

    if (prefixCastorUnderscore) {
        attName = addCastorUnderscore(att.getName());
    } else {
        attName = att.getName();
    }

    String name = parentAlias + "." + attName;
    String value = att.getValue();
    Criterion restriction = null;

    Predicate attPredicate = att.getPredicate();

    if (attPredicate.equals(Predicate.EQUAL_TO)) {
        restriction = Restrictions.eq(name, value);
    }
    if (attPredicate.equals(Predicate.LIKE)) {
        restriction = Restrictions.like(name, value);
    }
    if (attPredicate.equals(Predicate.GREATER_THAN)) {
        restriction = Restrictions.gt(name, value);
    }
    if (attPredicate.equals(Predicate.GREATER_THAN_EQUAL_TO)) {
        restriction = Restrictions.ge(name, value);
    }
    if (attPredicate.equals(Predicate.LESS_THAN)) {
        restriction = Restrictions.lt(name, value);
    }
    if (attPredicate.equals(Predicate.LESS_THAN_EQUAL_TO)) {
        restriction = Restrictions.le(name, value);
    }
    if (attPredicate.equals(Predicate.IS_NULL)) {
        restriction = Restrictions.isNull(name);
    }
    if (attPredicate.equals(Predicate.IS_NOT_NULL)) {
        restriction = Restrictions.isNotNull(name);
    }
    if (attPredicate.equals(Predicate.NOT_EQUAL_TO)) {
        restriction = Restrictions.ne(name, value);
    }
    return restriction;
}

From source file:org.LexGrid.LexBIG.caCore.dao.orm.translators.SDKCQLToDetachedCriteria.java

License:Open Source License

private Criterion processAttribute(CQLAttribute att, String parentAlias) {
    String name = parentAlias + "." + att.getName();
    String value = att.getValue();
    Criterion restriction = null;//from  w ww  .j  ava  2s. co  m

    CQLPredicate attPredicate = att.getPredicate();

    if (attPredicate.equals(CQLPredicate.EQUAL_TO)) {
        restriction = Restrictions.eq(name, value);
    }
    if (attPredicate.equals(CQLPredicate.LIKE)) {
        restriction = Restrictions.like(name, value);
    }
    if (attPredicate.equals(CQLPredicate.GREATER_THAN)) {
        restriction = Restrictions.gt(name, value);
    }
    if (attPredicate.equals(CQLPredicate.GREATER_THAN_EQUAL_TO)) {
        restriction = Restrictions.ge(name, value);
    }
    if (attPredicate.equals(CQLPredicate.LESS_THAN)) {
        restriction = Restrictions.lt(name, value);
    }
    if (attPredicate.equals(CQLPredicate.LESS_THAN_EQUAL_TO)) {
        restriction = Restrictions.le(name, value);
    }
    if (attPredicate.equals(CQLPredicate.IS_NULL)) {
        restriction = Restrictions.isNull(name);
    }
    if (attPredicate.equals(CQLPredicate.IS_NOT_NULL)) {
        restriction = Restrictions.isNotNull(name);
    }
    if (attPredicate.equals(CQLPredicate.NOT_EQUAL_TO)) {
        restriction = Restrictions.ne(name, value);
    }
    return restriction;
}

From source file:org.libreplan.business.orders.daos.OrderDAO.java

License:Open Source License

@Override
public List<Order> getOrdersWithNotEmptyCustomersReferences() {
    return getSession().createCriteria(Order.class).add(Restrictions.isNotNull("customerReference"))
            .add(Restrictions.ne("customerReference", "")).list();
}

From source file:org.libreplan.business.orders.daos.OrderElementDAO.java

License:Open Source License

@Override
public List<OrderElement> findOrderElementsWithExternalCode() {
    return getSession().createCriteria(OrderElement.class).add(Restrictions.isNotNull("externalCode")).list();
}

From source file:org.libreplan.business.planner.limiting.daos.LimitingResourceQueueElementDAO.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override//  ww  w  .jav a2 s .  c o m
public List<LimitingResourceQueueElement> getAssigned() {
    Criteria criteria = getSession().createCriteria(LimitingResourceQueueElement.class);
    criteria.add(Restrictions.isNotNull("limitingResourceQueue"));
    criteria.addOrder(Order.asc("creationTimestamp"));
    return criteria.list();
}

From source file:org.libreplan.business.resources.daos.WorkerDAO.java

License:Open Source License

@Override
@SuppressWarnings("unchecked")
public List<Worker> getBound() {
    Criteria criteria = getSession().createCriteria(Worker.class);
    criteria.add(Restrictions.isNotNull("user"));
    return criteria.list();
}

From source file:org.motechproject.mobile.core.dao.hibernate.GatewayRequestDAOImpl.java

License:Open Source License

/**
 *  @see {@link org.motechproject.mobile.core.dao.GatewayRequestDAO#getByStatusAndSchedule}
 *///from ww w .j a  va2s. c o  m
public List<GatewayRequest> getByStatusAndSchedule(MStatus status, Date schedule) {
    logger.debug("variables passed to getByStatusAndSchedule. status: " + status + "And schedule: " + schedule);

    try {

        List<GatewayRequest> allbystatandSdule;
        Criteria criteria = this.getSessionFactory().getCurrentSession().createCriteria(getPersistentClass());
        if (schedule == null) {
            criteria = criteria.add(Restrictions.isNull("dateTo")).add(Restrictions.isNull("dateFrom"))
                    .add(Restrictions.eq("messageStatus", status));
        } else {
            criteria = criteria.add(Restrictions.eq("messageStatus", status))
                    .add(Restrictions.or(Restrictions.isNull("dateFrom"),
                            Restrictions.lt("dateFrom", schedule)))
                    .add(Restrictions.or(Restrictions.isNull("dateTo"), Restrictions.gt("dateTo", schedule)));
        }

        allbystatandSdule = (List<GatewayRequest>) criteria.add(Restrictions.isNotNull("gatewayRequestDetails"))
                .list();
        logger.debug(allbystatandSdule);

        return allbystatandSdule;

    } catch (HibernateException he) {

        logger.error("Persistence or JDBC Exception in Method getByStatusAndSchedule", he);
        return null;
    } catch (Exception ex) {

        logger.error("Exception in Method getByStatusAndSchedule", ex);
        return null;
    }
}

From source file:org.motechproject.server.model.db.hibernate.HibernateMotechDAO.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<MessageProgramEnrollment> getActiveMessageProgramEnrollments(Integer personId, String program,
        Integer obsId, Long minExclusiveId, Integer maxResults) {
    Session session = sessionFactory.getCurrentSession();
    Criteria criteria = session.createCriteria(MessageProgramEnrollment.class);
    criteria.add(Restrictions.isNotNull("startDate"));
    criteria.add(Restrictions.isNull("endDate"));
    if (personId != null) {
        criteria.add(Restrictions.eq("personId", personId));
    }/*from ww  w .  j  a  v a2  s. c o m*/
    if (program != null) {
        criteria.add(Restrictions.eq("program", program));
    }
    if (obsId != null) {
        criteria.add(Restrictions.eq("obsId", obsId));
    }
    if (minExclusiveId != null) {
        criteria.add(Restrictions.gt("id", minExclusiveId));
    }
    if (maxResults != null) {
        criteria.setMaxResults(maxResults);
    }
    return (List<MessageProgramEnrollment>) criteria.addOrder(Order.asc("id")).list();
}

From source file:org.mzd.shap.domain.dao.FeatureDaoSpringHibernate.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<Feature> findBySampleAndAnnotator(final Sample sample, final Annotator annotator) {
    Object result = getHibernateTemplate().execute(new HibernateCallback() {
        public Object doInHibernate(Session session) throws HibernateException, SQLException {

            return session.createCriteria(getPersistentClass()).createAlias("annotations", "an")
                    .createAlias("sequence", "seq").add(Restrictions.eq("seq.sample", sample))
                    .add(Restrictions.eq("an.annotator", annotator))
                    .add(Restrictions.isNotNull("an.description")).list();
        }//from   w  w w . j a va  2s .c  om
    });
    return (List<Feature>) result;
}

From source file:org.n52.series.db.dao.DatasetDao.java

License:Open Source License

private LogicalExpression createNotNullFirstLastValueRestriction(String alias) {
    return Restrictions.and(Restrictions.isNotNull(alias.concat("firstValueAt")),
            Restrictions.isNotNull(alias.concat("lastValueAt")));
}