Example usage for org.hibernate.criterion Restrictions lt

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

Introduction

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

Prototype

public static SimpleExpression lt(String propertyName, Object value) 

Source Link

Document

Apply a "less than" constraint to the named property

Usage

From source file:jp.ac.tokushima_u.is.ll.common.orm.hibernate.HibernateDao.java

License:Apache License

/**
 * ??Criterion?,.//w ww .j a  v  a  2 s  . c  om
 */
protected Criterion buildPropertyFilterCriterion(final String propertyName, final Object propertyValue,
        final MatchType matchType) {
    Assert.hasText(propertyName, "propertyName should not be null");
    Criterion criterion = null;
    try {

        //MatchType?criterion?
        if (MatchType.EQ.equals(matchType)) {
            criterion = Restrictions.eq(propertyName, propertyValue);
        } else if (MatchType.LIKE.equals(matchType)) {
            criterion = Restrictions.like(propertyName, (String) propertyValue, MatchMode.ANYWHERE);
        } else if (MatchType.LE.equals(matchType)) {
            criterion = Restrictions.le(propertyName, propertyValue);
        } else if (MatchType.LT.equals(matchType)) {
            criterion = Restrictions.lt(propertyName, propertyValue);
        } else if (MatchType.GE.equals(matchType)) {
            criterion = Restrictions.ge(propertyName, propertyValue);
        } else if (MatchType.GT.equals(matchType)) {
            criterion = Restrictions.gt(propertyName, propertyValue);
        }
    } catch (Exception e) {
        throw ReflectionUtils.convertReflectionExceptionToUnchecked(e);
    }
    return criterion;
}

From source file:main.java.info.jtrac.domain.ColumnHeading.java

License:Apache License

private Object process(Component c, DetachedCriteria criteria) {
    boolean forFragment = c != null;
    List<Expression> list = new ArrayList<Expression>();
    Fragment fragment = null;/*  ww w.j  a v  a  2  s.  c om*/
    List values = filterCriteria.getValues();
    Object value = filterCriteria.getValue();
    Object value2 = filterCriteria.getValue2();
    Expression expression = filterCriteria.getExpression();
    if (isField()) {
        switch (field.getName().getType()) {
        case 1:
        case 2:
        case 3:
            list.add(Expression.IN);
            if (forFragment) {
                fragment = new Fragment("fragParent", "multiSelect");
                final Map<String, String> options = field.getOptions();
                JtracCheckBoxMultipleChoice choice = new JtracCheckBoxMultipleChoice("values",
                        new ArrayList(options.keySet()), new IChoiceRenderer() {
                            /**
                            * 
                            */
                            private static final long serialVersionUID = 1L;

                            public Object getDisplayValue(Object o) {
                                return options.get(o);
                            }

                            public String getIdValue(Object o, int i) {
                                return o.toString();
                            }
                        });
                fragment.add(choice);
                choice.setModel(new PropertyModel(this, "filterCriteria.values"));
            }
            if (filterHasValueList(criteria)) {
                List<Integer> keys = new ArrayList<Integer>(values.size());
                for (Object o : values) {
                    keys.add(new Integer(o.toString()));
                }
                criteria.add(Restrictions.in(name, keys));
            }
            break; // drop down list
        case 4: // decimal number
            list.add(Expression.EQ);
            list.add(Expression.NOT_EQ);
            list.add(Expression.GT);
            list.add(Expression.LT);
            list.add(Expression.BETWEEN);
            if (forFragment) {
                fragment = new Fragment("fragParent", "textField");
                TextField textField = new TextField("value", Double.class);
                textField.setModel(new PropertyModel(this, "filterCriteria.value"));
                fragment.add(textField);
                if (expression == Expression.BETWEEN) {
                    TextField textField2 = new TextField("value2", Double.class);
                    textField.setModel(new PropertyModel(this, "filterCriteria.value2"));
                    fragment.add(textField2);
                } else {
                    fragment.add(new WebMarkupContainer("value2").setVisible(false));
                }
            }
            if (filterHasValue(criteria)) {
                switch (expression) {
                case EQ:
                    criteria.add(Restrictions.eq(name, value));
                    break;
                case NOT_EQ:
                    criteria.add(Restrictions.not(Restrictions.eq(name, value)));
                    break;
                case GT:
                    criteria.add(Restrictions.gt(name, value));
                    break;
                case LT:
                    criteria.add(Restrictions.lt(name, value));
                    break;
                case BETWEEN:
                    criteria.add(Restrictions.gt(name, value));
                    criteria.add(Restrictions.lt(name, value2));
                    break;
                default:
                }
            }
            break;
        case 6: // date
            list.add(Expression.EQ);
            list.add(Expression.NOT_EQ);
            list.add(Expression.GT);
            list.add(Expression.LT);
            list.add(Expression.BETWEEN);
            if (forFragment) {
                fragment = new Fragment("fragParent", "dateField");
                YuiCalendar calendar = new YuiCalendar("value", new PropertyModel(this, "filterCriteria.value"),
                        false);
                fragment.add(calendar);
                if (filterCriteria.getExpression() == Expression.BETWEEN) {
                    YuiCalendar calendar2 = new YuiCalendar("value2",
                            new PropertyModel(this, "filterCriteria.value2"), false);
                    fragment.add(calendar2);
                } else {
                    fragment.add(new WebMarkupContainer("value2").setVisible(false));
                }
            }
            if (filterHasValue(criteria)) {
                switch (expression) {
                case EQ:
                    criteria.add(Restrictions.eq(name, value));
                    break;
                case NOT_EQ:
                    criteria.add(Restrictions.not(Restrictions.eq(name, value)));
                    break;
                case GT:
                    criteria.add(Restrictions.gt(name, value));
                    break;
                case LT:
                    criteria.add(Restrictions.lt(name, value));
                    break;
                case BETWEEN:
                    criteria.add(Restrictions.gt(name, value));
                    criteria.add(Restrictions.lt(name, value2));
                    break;
                default:
                }
            }
            break;
        case 5: // free text
            list.add(Expression.CONTAINS);
            if (forFragment) {
                fragment = new Fragment("fragParent", "textField");
                TextField textField = new TextField("value", String.class);
                textField.setModel(new PropertyModel(this, "filterCriteria.value"));
                fragment.add(textField);
                fragment.add(new WebMarkupContainer("value2").setVisible(false));
            }
            if (filterHasValue(criteria)) {
                criteria.add(Restrictions.ilike(name, (String) value, MatchMode.ANYWHERE));
            }
            break;
        default:
            throw new RuntimeException("Unknown Column Heading " + name);
        }
    } else {
        if (name.equals(ID)) {
            list.add(Expression.EQ);
            if (forFragment) {
                fragment = new Fragment("fragParent", "textField");
                TextField textField = new TextField("value", String.class);
                textField.setModel(new PropertyModel(this, "filterCriteria.value"));
                fragment.add(textField);
                fragment.add(new WebMarkupContainer("value2").setVisible(false));
            }
            // should never come here for criteria: see ItemSearch#getRefId()
        } else if (name.equals(SUMMARY)) {
            list.add(Expression.CONTAINS);
            if (forFragment) {
                fragment = new Fragment("fragParent", "textField");
                TextField textField = new TextField("value", String.class);
                textField.setModel(new PropertyModel(this, "filterCriteria.value"));
                fragment.add(textField);
                fragment.add(new WebMarkupContainer("value2").setVisible(false));
            }
            if (filterHasValue(criteria)) {
                criteria.add(Restrictions.ilike(name, (String) value, MatchMode.ANYWHERE));
            }
        } else if (name.equals(DETAIL)) {
            list.add(Expression.CONTAINS);
            if (forFragment) {
                fragment = new Fragment("fragParent", "textField");
                TextField textField = new TextField("value", String.class);
                textField.setModel(new PropertyModel(this, "filterCriteria.value"));
                fragment.add(textField);
                fragment.add(new WebMarkupContainer("value2").setVisible(false));
            }
            // should never come here for criteria: see ItemSearch#getSearchText()
        } else if (name.equals(STATUS)) {
            list.add(Expression.IN);
            if (forFragment) {
                fragment = new Fragment("fragParent", "multiSelect");
                final Map<Integer, String> options = ComponentUtils.getCurrentSpace(c).getMetadata()
                        .getStates();
                options.remove(State.NEW);
                JtracCheckBoxMultipleChoice choice = new JtracCheckBoxMultipleChoice("values",
                        new ArrayList(options.keySet()), new IChoiceRenderer() {
                            /**
                            * 
                            */
                            private static final long serialVersionUID = 1L;

                            public Object getDisplayValue(Object o) {
                                return options.get(o);
                            }

                            public String getIdValue(Object o, int i) {
                                return o.toString();
                            }
                        });
                fragment.add(choice);
                choice.setModel(new PropertyModel(this, "filterCriteria.values"));
            }
            if (filterHasValueList(criteria)) {
                criteria.add(Restrictions.in(name, filterCriteria.getValues()));
            }
        } else if (name.equals(ASSIGNED_TO) || name.equals(LOGGED_BY)) {
            list.add(Expression.IN);
            if (forFragment) {
                fragment = new Fragment("fragParent", "multiSelect");
                List<User> users = null;
                Space s = ComponentUtils.getCurrentSpace(c);
                if (s == null) {
                    User u = ComponentUtils.getPrincipal(c);
                    users = ComponentUtils.getJtrac(c).findUsersForUser(u);
                } else {
                    users = ComponentUtils.getJtrac(c).findUsersForSpace(s.getId());
                }
                JtracCheckBoxMultipleChoice choice = new JtracCheckBoxMultipleChoice("values", users,
                        new IChoiceRenderer() {
                            /**
                            * 
                            */
                            private static final long serialVersionUID = 1L;

                            public Object getDisplayValue(Object o) {
                                return ((User) o).getName();
                            }

                            public String getIdValue(Object o, int i) {
                                return ((User) o).getId() + "";
                            }
                        });
                fragment.add(choice);
                choice.setModel(new PropertyModel(this, "filterCriteria.values"));
            }
            if (filterHasValueList(criteria)) {
                criteria.add(Restrictions.in(name, filterCriteria.getValues()));
            }
        } else if (name.equals(TIME_STAMP)) {
            list.add(Expression.BETWEEN);
            list.add(Expression.GT);
            list.add(Expression.LT);
            if (forFragment) {
                fragment = new Fragment("fragParent", "dateField");
                YuiCalendar calendar = new YuiCalendar("value", new PropertyModel(this, "filterCriteria.value"),
                        false);
                fragment.add(calendar);
                if (expression == Expression.BETWEEN) {
                    YuiCalendar calendar2 = new YuiCalendar("value2",
                            new PropertyModel(this, "filterCriteria.value2"), false);
                    fragment.add(calendar2);
                } else {
                    fragment.add(new WebMarkupContainer("value2").setVisible(false));
                }
            }
            if (filterHasValue(criteria)) {
                switch (expression) {
                case GT:
                    criteria.add(Restrictions.gt(name, value));
                    break;
                case LT:
                    criteria.add(Restrictions.lt(name, value));
                    break;
                case BETWEEN:
                    criteria.add(Restrictions.gt(name, value));
                    criteria.add(Restrictions.lt(name, value2));
                    break;
                default:
                }
            }
        } else if (name.equals(SPACE)) {
            list.add(Expression.IN);
            if (forFragment) {
                fragment = new Fragment("fragParent", "multiSelect");
                List<Space> spaces = new ArrayList(ComponentUtils.getPrincipal(c).getSpaces());
                JtracCheckBoxMultipleChoice choice = new JtracCheckBoxMultipleChoice("values", spaces,
                        new IChoiceRenderer() {
                            /**
                            * 
                            */
                            private static final long serialVersionUID = 1L;

                            public Object getDisplayValue(Object o) {
                                return ((Space) o).getName();
                            }

                            public String getIdValue(Object o, int i) {
                                return ((Space) o).getId() + "";
                            }
                        });
                fragment.add(choice);
                choice.setModel(new PropertyModel(this, "filterCriteria.values"));
            }
            // should never come here for criteria: see ItemSearch#getSelectedSpaces()
        } else {
            throw new RuntimeException("Unknown Column Heading " + name);
        }
    }
    if (forFragment) {
        return fragment;
    } else {
        return list;
    }
}

From source file:mitm.common.hibernate.HibernateDatabaseCriterion.java

License:Open Source License

private Criterion createLTCriterion() {
    return Restrictions.lt(property, value);
}

From source file:mitm.common.mail.repository.hibernate.MailRepositoryDAO.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<MailRepositoryItemEntity> getItemsBefore(String repository, Date before, Integer firstResult,
        Integer maxResults) {/*from   www  .ja  va  2s  . c  om*/
    Criteria criteria = createCriteria(entityName);
    criteria.add(Restrictions.eq(MailRepositoryItemEntity.REPOSITORY_COLUMN_NAME, repository));
    criteria.add(Restrictions.lt(MailRepositoryItemEntity.CREATED_COLUMN_NAME, before));

    criteria.addOrder(Order.asc(MailRepositoryItemEntity.CREATED_COLUMN_NAME));

    if (firstResult != null) {
        criteria.setFirstResult(firstResult);
    }

    if (maxResults != null) {
        criteria.setMaxResults(maxResults);
    }

    return criteria.list();
}

From source file:mitm.common.security.certstore.dao.X509CertStoreDAOHibernate.java

License:Open Source License

/**
 * Helper function that returns the number of records that searchField would return.
 *//*from   w w w .j ava  2s  .  co  m*/
private int getSearchFieldCount(Field field, String search, Expired expired, MissingKeyAlias missingKeyAlias,
        Date date) {
    Criteria criteria = createCriteria(entityName);

    criteria.setProjection(Projections.rowCount());

    criteria.add(Restrictions.eq(getColumnName(Field.STORE_NAME), storeName));

    criteria.add(Restrictions.ilike(getColumnName(field), search));

    if (expired == Expired.NOT_ALLOWED) {
        criteria.add(Restrictions.lt(getColumnName(Field.NOT_BEFORE), date));
        criteria.add(Restrictions.gt(getColumnName(Field.NOT_AFTER), date));
    }

    if (missingKeyAlias == MissingKeyAlias.NOT_ALLOWED) {
        criteria.add(Restrictions.isNotNull(getColumnName(Field.KEY_ALIAS)));
    }

    return (Integer) criteria.uniqueResult();
}

From source file:mitm.common.security.certstore.dao.X509CertStoreDAOHibernate.java

License:Open Source License

@Override
public int getRowCount(Expired expired, MissingKeyAlias missingKeyAlias, Date date) {
    Criteria criteria = createCriteria(entityName);

    criteria.setProjection(Projections.rowCount());

    criteria.add(Restrictions.eq(getColumnName(Field.STORE_NAME), storeName));

    if (expired == Expired.NOT_ALLOWED) {
        criteria.add(Restrictions.lt(getColumnName(Field.NOT_BEFORE), date));
        criteria.add(Restrictions.gt(getColumnName(Field.NOT_AFTER), date));
    }//from   ww w  .jav a 2  s  .  c om

    if (missingKeyAlias == MissingKeyAlias.NOT_ALLOWED) {
        criteria.add(Restrictions.isNotNull(getColumnName(Field.KEY_ALIAS)));
    }

    return (Integer) criteria.uniqueResult();
}

From source file:mitm.common.security.crlstore.dao.X509CRLStoreDAOHibernate.java

License:Open Source License

private void addSelectorCriterias(X509CRLSelector crlSelector, Criteria criteria) {
    Collection<X500Principal> crlSelectorIssuers = crlSelector.getIssuers();

    if (crlSelectorIssuers != null && crlSelectorIssuers.size() > 0) {
        Disjunction issuerCriteria = Restrictions.disjunction();

        for (X500Principal issuer : crlSelectorIssuers) {
            String issuerCanonical = X500PrincipalInspector.getCanonical(issuer);

            issuerCriteria.add(Restrictions.eq("crl.issuer", issuerCanonical));
        }/*from  w w  w  . ja  va 2  s . c o m*/

        criteria.add(issuerCriteria);
    }

    Date dateAndTime = crlSelector.getDateAndTime();

    if (dateAndTime != null) {
        criteria.add(Restrictions.lt("crl.thisUpdate", dateAndTime));
        criteria.add(Restrictions.gt("crl.nextUpdate", dateAndTime));
    }
}

From source file:Mob.MobLoginLog.java

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    try (PrintWriter out = resp.getWriter()) {
        DataInputStream da = new DataInputStream(req.getInputStream());
        String datefrm = da.readUTF(); //readLine();
        String dateto = da.readUTF(); //readLine();
        String utype = da.readUTF(); //readLine();
        da.close();// www.ja  v a  2s  .co  m

        //            System.out.println(datefrm);
        //            System.out.println(dateto);
        //            System.out.println(utype);
        String datefrmarr[] = datefrm.split(" ");
        String datetoarr[] = dateto.split(" ");

        SimpleDateFormat sdf = new SimpleDateFormat("MMM/dd/yyyy");

        Session con = FactoryManager.getSessionFactory().openSession();
        Criteria cri = con.createCriteria(LoginSession.class);

        if (datefrm != null && dateto != null) {
            if (!datefrm.equals("")) {
                Date d = sdf.parse(datefrmarr[1] + "/" + datefrmarr[2] + "/" + datefrmarr[5]);
                cri.add(Restrictions.ge("loginTime", d));
            }
            if (!dateto.equals("")) {
                Date d = sdf.parse(datetoarr[1] + "/" + datetoarr[2] + "/" + datetoarr[5]);
                cri.add(Restrictions.lt("loginTime", d));
            }
        }

        List<LoginSession> list = cri.list();

        int type = 0;
        if (utype.equals("1") || utype.equals("2")) {
            type = 1;
        }

        String output = "";
        for (LoginSession ll : list) {
            if (type == 1) {
                if (ll.getUser().getUserType().getGuestId().equals(2)
                        || ll.getUser().getUserType().getGuestId().equals(3)) {
                    output += ll.getUser().getEmail();
                    output += "-";
                    output += ll.getUser().getUserType().getType();
                    output += "-";
                    output += ll.getLoginTime().toString();
                    output += ",";
                }
            } else if (type == 0) {
                output += ll.getUser().getEmail();
                output += "-";
                output += ll.getUser().getUserType().getType();
                output += "-";
                output += ll.getLoginTime().toString();
                output += ",";
            }
        }

        out.print(output);

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:models.Journal.java

public Journals getPreviousRow(Integer id) {
    Session session = DatabaseUtil.getSessionFactory().openSession();
    Transaction tx = null;//from  www.  ja va  2  s.c  om
    Journals jn = null;
    try {
        tx = (Transaction) session.getTransaction();
        tx.begin();
        Criteria criteria = session.createCriteria(Journals.class);
        criteria.add(Restrictions.lt("id", id));
        criteria.addOrder(Order.desc("id"));
        criteria.setMaxResults(1);
        jn = (Journals) criteria.uniqueResult();
        tx.commit();
    } catch (HibernateException ex) {
        System.out.println(ex.getMessage());
        if (tx != null) {
            tx.rollback();
        }
    } finally {
        session.close();
    }
    return jn;
}

From source file:moos.ssds.dao.DataContainerDAO.java

License:LGPL

private Criteria formulatePropertyCriteria(boolean countQuery, Long id, String name, boolean exactNameMatch,
        String dataContainerType, Date startDate, boolean boundedByStartDate, Date endDate,
        boolean boundedByEndDate, String uriString, boolean exactUriMatch, String mimeType,
        boolean exactMimeTypeMatch, String dodsUrlString, boolean exactDodsUrlStringMatch,
        Double geospatialLatMin, boolean boundedByLatMin, Double geospatialLatMax, boolean boundedByLatMax,
        Double geospatialLonMin, boolean boundedByLonMin, Double geospatialLonMax, boolean boundedByLonMax,
        Float geospatialDepthMin, boolean boundedByDepthMin, Float geospatialDepthMax,
        boolean boundedByDepthMax, String orderByProperty, String ascendingOrDescending)
        throws MetadataAccessException {
    // The Criteria to return
    Criteria criteria = getSession().createCriteria(DataContainer.class);
    // Make the return distinct
    criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);

    // Check for exceptional conditions on the query
    if ((dataContainerType != null) && (!DataContainer.isValidDataContainerType(dataContainerType)))
        throw new MetadataAccessException("The dataContainerType (" + dataContainerType
                + ") does not match a constant defined in the DataContainer class");
    if ((geospatialLatMin != null) && (geospatialLatMax != null))
        if (geospatialLatMax.doubleValue() < geospatialLatMin.doubleValue())
            throw new MetadataAccessException("The maximum latitude specified was less than the minimum.");
    if ((geospatialLonMin != null) && (geospatialLonMax != null))
        if (geospatialLonMax.doubleValue() < geospatialLonMin.doubleValue())
            throw new MetadataAccessException("The maximum longitude specified was less than the minimum.");
    if ((geospatialDepthMin != null) && (geospatialDepthMax != null))
        if (geospatialDepthMax.doubleValue() < geospatialDepthMin.doubleValue())
            throw new MetadataAccessException("The depth maximum specified was less than the minimum.");
    if ((startDate != null) && (endDate != null) && (endDate.before(startDate)))
        throw new MetadataAccessException("The end date specified (" + endDate
                + ") is before the start date specified (" + startDate + ")");

    if (id != null) {
        criteria.add(Restrictions.eq("id", id));
    } else {/*from w  w w.ja  v  a2 s .  co m*/
        if ((name != null) && (!name.equals(""))) {
            if (exactNameMatch) {
                criteria.add(Restrictions.eq("name", name));
            } else {
                criteria.add(Restrictions.like("name", "%" + name + "%"));
            }
        }
        if (dataContainerType != null) {
            criteria.add(Restrictions.eq("dataContainerType", dataContainerType));
        }
        if (startDate != null) {
            criteria.add(Restrictions.gt("endDate", startDate));
            if (boundedByStartDate) {
                criteria.add(Restrictions.gt("startDate", startDate));
            }
        }
        if (endDate != null) {
            criteria.add(Restrictions.lt("startDate", endDate));
            if (boundedByEndDate) {
                criteria.add(Restrictions.lt("endDate", endDate));
            }
        }
        if (uriString != null) {
            if (exactUriMatch) {
                criteria.add(Restrictions.eq("uriString", uriString));
            } else {
                criteria.add(Restrictions.like("uriString", "%" + uriString + "%"));
            }
        }
        if (mimeType != null) {
            if (exactMimeTypeMatch) {
                criteria.add(Restrictions.eq("mimeType", mimeType));
            } else {
                criteria.add(Restrictions.like("mimdType", "%" + mimeType + "%"));
            }
        }
        if (dodsUrlString != null) {
            if (exactDodsUrlStringMatch) {
                criteria.add(Restrictions.eq("dodsUrlString", dodsUrlString));
            } else {
                criteria.add(Restrictions.like("dodsUrlString", "%" + dodsUrlString + "%"));
            }
        }
        if (geospatialLatMin != null) {
            criteria.add(Restrictions.gt("maxLatitude", geospatialLatMin));
            if (boundedByLatMin) {
                criteria.add(Restrictions.ge("minLatitude", geospatialLatMin));
            }
        }

        if (geospatialLatMax != null) {
            criteria.add(Restrictions.lt("minLatitude", geospatialLatMax));
            if (boundedByLatMax) {
                criteria.add(Restrictions.le("maxLatitude", geospatialLatMax));
            }
        }

        if (geospatialLonMin != null) {
            criteria.add(Restrictions.gt("maxLongitude", geospatialLonMin));
            if (boundedByLonMin) {
                criteria.add(Restrictions.ge("minLongitude", geospatialLonMin));
            }
        }

        if (geospatialLonMax != null) {
            criteria.add(Restrictions.lt("minLongitude", geospatialLonMax));
            if (boundedByLonMax) {
                criteria.add(Restrictions.le("maxLongitude", geospatialLonMax));
            }
        }

        if (geospatialDepthMin != null) {
            criteria.add(Restrictions.gt("maxDepth", geospatialDepthMin));
            if (boundedByDepthMin) {
                criteria.add(Restrictions.ge("minDepth", geospatialDepthMin));
            }
        }

        if (geospatialDepthMax != null) {
            criteria.add(Restrictions.lt("minDepth", geospatialDepthMax));
            if (boundedByDepthMax) {
                criteria.add(Restrictions.le("maxDepth", geospatialDepthMax));
            }
        }

    }
    // Setup if a count query, if not add fetching and ordering
    if (countQuery) {
        criteria.setProjection(Projections.rowCount());
    } else {
        addOrderByCriteria(criteria, orderByProperty, ascendingOrDescending);
    }
    // Now return the Criteria
    return criteria;
}