Example usage for org.hibernate.criterion Restrictions ne

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

Introduction

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

Prototype

public static SimpleExpression ne(String propertyName, Object value) 

Source Link

Document

Apply a "not equal" constraint to the named property

Usage

From source file:org.libreplan.business.workreports.daos.WorkReportLineDAO.java

License:Open Source License

@Override
@SuppressWarnings("unchecked")
public List<WorkReportLine> findByResourceFilteredByDateNotInWorkReport(Resource resource, Date start, Date end,
        WorkReport workReport) {//  w w  w.j  a va2 s. c om
    Criteria criteria = getSession().createCriteria(WorkReportLine.class);
    criteria.add(Restrictions.eq("resource", resource));

    criteria.add(Restrictions.ge("date", start));
    criteria.add(Restrictions.le("date", end));

    if (workReport != null) {
        criteria.add(Restrictions.ne("workReport", workReport));
    }

    return criteria.list();
}

From source file:org.libreplan.business.workreports.daos.WorkReportLineDAO.java

License:Open Source License

@SuppressWarnings("unchecked")
private List<WorkReportLine> findFinishedByOrderElementNotInWorkReport(OrderElement orderElement,
        WorkReport workReport) {/*ww w .j  av  a  2s. c o m*/
    Criteria criteria = getSession().createCriteria(WorkReportLine.class);

    criteria.add(Restrictions.eq("orderElement", orderElement));
    if (!workReport.isNewObject()) {
        criteria.add(Restrictions.ne("workReport", workReport));
    }
    criteria.add(Restrictions.eq("finished", true));

    return (List<WorkReportLine>) criteria.list();
}

From source file:org.linagora.linshare.core.repository.hibernate.MailingListRepositoryImpl.java

License:Open Source License

@Override
public List<MailingList> searchListWithInput(User user, String input) {
    DetachedCriteria det = DetachedCriteria.forClass(getPersistentClass());

    if (user.isSuperAdmin()) {
        det.add(Restrictions.like("identifier", "%" + input + "%").ignoreCase());
    } else {//from w w w.  j av a  2  s . c om
        // all public lists that belong to my domain.
        LogicalExpression allPublicLists = Restrictions.and(Restrictions.eq("isPublic", true),
                Restrictions.eq("domain", user.getDomain()));
        // we exclude my personal lists.
        LogicalExpression allMyDomainPublicLists = Restrictions.and(allPublicLists,
                Restrictions.ne("owner", user));
        // adding all private and public lists that belong to me, to the
        // public
        // lists.

        LogicalExpression allMyLists = Restrictions.or(Restrictions.eq("owner", user), allMyDomainPublicLists);
        det.add(Restrictions.and(allMyLists, Restrictions.like("identifier", "%" + input + "%").ignoreCase()));
    }
    det.addOrder(Property.forName("identifier").desc());

    return findByCriteria(det);
}

From source file:org.linagora.linshare.core.repository.hibernate.MailingListRepositoryImpl.java

License:Open Source License

@Override
public List<MailingList> findAllMyList(User user) {
    if (user.isSuperAdmin()) {
        return findAll();
    }//from  ww w. ja v a 2 s  .c o m

    DetachedCriteria det = DetachedCriteria.forClass(getPersistentClass());

    // all public lists that belong to my domain.
    LogicalExpression allPublicLists = Restrictions.and(Restrictions.eq("isPublic", true),
            Restrictions.eq("domain", user.getDomain()));
    // we exclude my personal lists.
    LogicalExpression allMyDomainPublicLists = Restrictions.and(allPublicLists, Restrictions.ne("owner", user));
    // adding all private and public lists that belong to me, to the public
    // lists.
    det.add(Restrictions.or(Restrictions.eq("owner", user), allMyDomainPublicLists));

    return findByCriteria(det);
}

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

License:Open Source License

@SuppressWarnings("unchecked")
public List<Message> getMessages(Integer recipientId, MessageProgramEnrollment enrollment,
        MessageDefinition definition, Date messageDate, MessageStatus status) {
    Session session = sessionFactory.getCurrentSession();
    return (List<Message>) session.createCriteria(Message.class).add(Restrictions.eq("attemptStatus", status))
            .createCriteria("schedule").add(Restrictions.eq("recipientId", recipientId))
            .add(Restrictions.eq("enrollment", enrollment)).add(Restrictions
                    .or(Restrictions.ne("message", definition), Restrictions.ne("scheduledFor", messageDate)))
            .list();/*from   ww w . jav  a  2s  .c o m*/
}

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

License:Open Source License

@SuppressWarnings("unchecked")
public List<Message> getMessages(Integer recipientId, MessageProgramEnrollment enrollment,
        MessageDefDate[] messageDefDates, MessageStatus status) {
    Session session = sessionFactory.getCurrentSession();
    Criteria criteria = session.createCriteria(Message.class).add(Restrictions.eq("attemptStatus", status))
            .createCriteria("schedule").add(Restrictions.eq("recipientId", recipientId))
            .add(Restrictions.eq("enrollment", enrollment));

    Conjunction notMatchMessages = Restrictions.conjunction();
    for (MessageDefDate messageDefDate : messageDefDates) {
        notMatchMessages.add(Restrictions.or(Restrictions.ne("message", messageDefDate.getMessage()),
                Restrictions.ne("scheduledFor", messageDefDate.getDate())));
    }/* w  w  w.  jav a 2  s.  c om*/
    criteria.add(notMatchMessages);

    return criteria.list();
}

From source file:org.mzd.shap.spring.task.JobDaoSpringHibernate.java

License:Open Source License

public Job findUnfinishedById(final Integer jobId) {
    return getHibernateTemplate().execute(new HibernateCallback<Job>() {
        public Job doInHibernate(Session session) throws HibernateException, SQLException {
            return (Job) session.createCriteria(getPersistentClass()).add(Restrictions.idEq(jobId))
                    .add(Restrictions.conjunction().add(Restrictions.ne("status", Status.DONE))
                            .add(Restrictions.ne("status", Status.ERROR)))
                    .uniqueResult();/*from  w  ww  .j a  v a2  s  .c  om*/
        }
    });
}

From source file:org.n52.sos.ds.hibernate.dao.FeatureOfInterestTypeDAO.java

License:Open Source License

/**
 * Get all featureOfInterest types/*from  w  w w. j a va2s.co  m*/
 * 
 * @param session
 *            Hibernate session
 * @return All featureOfInterest types
 */
@SuppressWarnings("unchecked")
public List<String> getFeatureOfInterestTypes(final Session session) {
    Criteria criteria = session.createCriteria(FeatureOfInterestType.class)
            .add(Restrictions.ne(FeatureOfInterestType.FEATURE_OF_INTEREST_TYPE, OGCConstants.UNKNOWN))
            .setProjection(
                    Projections.distinct(Projections.property(FeatureOfInterestType.FEATURE_OF_INTEREST_TYPE)));

    LOGGER.debug("QUERY getFeatureOfInterestTypes(): {}", HibernateHelper.getSqlString(criteria));
    return criteria.list();
}

From source file:org.n52.sos.ds.hibernate.util.HibernateCriteriaQueryUtilities.java

License:Open Source License

@Deprecated
@SuppressWarnings("unchecked")
public static List<String> getFeatureOfInterestTypes(Session session) {
    return session.createCriteria(FeatureOfInterestType.class)
            .add(Restrictions.ne(FeatureOfInterestType.FEATURE_OF_INTEREST_TYPE, OGCConstants.UNKNOWN))
            .setProjection(// w  w w  . j a v  a 2s  .c  om
                    Projections.distinct(Projections.property(FeatureOfInterestType.FEATURE_OF_INTEREST_TYPE)))
            .list();
}

From source file:org.nema.medical.mint.server.domain.StudyDAO.java

License:Apache License

@SuppressWarnings("unchecked")
public List<MINTStudy> findStudies(final String studyInstanceUID, final String accessionNumber,
        final String accessionNumberIssuer, final String patientID, final String patientIDIssuer,
        final Date minStudyDateTime, final Date minStudyDate, final Date maxStudyDateTime,
        final Date maxStudyDate, final int limit, final int offset) throws DateTimeParseException {

    final DetachedCriteria detachedCriteria = DetachedCriteria.forClass(MINTStudy.class);
    detachedCriteria.addOrder(Order.desc("lastModified"));

    if (studyInstanceUID != null && StringUtils.isNotBlank(studyInstanceUID)) {
        detachedCriteria.add(Restrictions.eq("studyInstanceUID", studyInstanceUID));
    }//  w  ww .j a va 2s.  com
    if (accessionNumber != null && StringUtils.isNotBlank(accessionNumber)) {
        detachedCriteria.add(Restrictions.eq("accessionNumber", accessionNumber));
    }
    if (accessionNumberIssuer != null && StringUtils.isNotBlank(accessionNumberIssuer)) {
        detachedCriteria.add(Restrictions.eq("issuerOfAccessionNumber", accessionNumberIssuer));
    }
    if (patientID != null && StringUtils.isNotBlank(patientID)) {
        detachedCriteria.add(Restrictions.eq("patientID", patientID));
    }
    if (patientIDIssuer != null && StringUtils.isNotBlank(patientIDIssuer)) {
        detachedCriteria.add(Restrictions.eq("issuerOfPatientID", patientIDIssuer));
    }
    if (minStudyDateTime != null) {
        detachedCriteria.add(Restrictions.ge("dateTime", minStudyDateTime));
    }
    if (minStudyDate != null) {
        detachedCriteria.add(Restrictions.ge("dateTime", minStudyDate));
    }
    if (maxStudyDateTime != null) {
        detachedCriteria.add(Restrictions.le("dateTime", maxStudyDateTime));
    }
    if (maxStudyDate != null) {
        detachedCriteria.add(Restrictions.lt("dateTime", maxStudyDate));
    }

    //Eliminate deleted studies from search results
    detachedCriteria.add(Restrictions.ne("studyVersion", -1));

    int firstResult = (offset - 1) * limit;
    final List<MINTStudy> list = (List<MINTStudy>) getHibernateTemplate().findByCriteria(detachedCriteria,
            firstResult, limit);
    return list;
}