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:com.ut.tekir.finance.InvoiceMatchHomeBean.java

License:LGPL

@Override
public DetachedCriteria buildCriteria() {
    DetachedCriteria crit = DetachedCriteria.forClass(Invoice.class);

    crit.setProjection(Projections.projectionList().add(Projections.property("this.serial"), "serial")
            .add(Projections.property("this.contact"), "contact")
            .add(Projections.property("this.reference"), "reference")
            .add(Projections.property("this.action"), "action")
            .add(Projections.property("this.invoiceTotal.currency"), "invoiceCurrency")
            .add(Projections.property("this.invoiceTotal.value"), "invoiceValue")
            .add(Projections.property("this.date"), "date")
            .add(Projections.property("this.id"), "matchedDocumentId"));

    crit.add(Restrictions.ne("this.matchingFinished", Boolean.TRUE));

    crit.setResultTransformer(Transformers.aliasToBean(InvoiceMatchFilterModel.class));

    if (filterModel.getSerial() != null && filterModel.getSerial().length() > 0) {
        crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START));
    }//from   w  w w.  j  a  va  2  s  .  c om

    if (filterModel.getReference() != null && filterModel.getReference().length() > 0) {
        crit.add(Restrictions.ilike("this.reference", filterModel.getReference(), MatchMode.START));
    }

    if (filterModel.getCode() != null && filterModel.getCode().length() > 0) {
        crit.add(Restrictions.ilike("this.code", filterModel.getCode(), MatchMode.START));
    }

    if (getContact() != null) {
        crit.add(Restrictions.eq("this.contact", getContact()));
    }

    if (filterModel.getBeginDate() != null) {
        crit.add(Restrictions.ge("this.date", filterModel.getBeginDate()));
    }

    if (filterModel.getEndDate() != null) {
        crit.add(Restrictions.le("this.date", filterModel.getEndDate()));
    }

    if (tradeAction != null) {
        crit.add(Restrictions.eq("this.action", tradeAction));
    }

    crit.addOrder(Order.desc("this.serial"));

    return crit;
}

From source file:com.ut.tekir.finance.PromissoryChangeLastStatusBean.java

License:LGPL

@Override
public DetachedCriteria buildCriteria() {

    DetachedCriteria crit = DetachedCriteria.forClass(PromissoryNote.class);

    crit.createAlias("this.history", "history");

    if (isNotEmpty(filterModel.getReferenceNo())) {
        crit.add(Restrictions.eq("referenceNo", filterModel.getReferenceNo()));
    }/*from  w w  w . j a v a2 s.co m*/

    if (filterModel.getContact() != null) {
        crit.add(Restrictions.eq("contact", filterModel.getContact()));
    }

    if (isNotEmpty(filterModel.getPromissorynoteOwner())) {
        crit.add(Restrictions.like("promissorynoteOwner", filterModel.getPromissorynoteOwner() + "%"));
    }

    if (filterModel.getBeginDate() != null) {
        crit.add(Restrictions.ge("history.date", filterModel.getBeginDate()));
    }

    if (filterModel.getEndDate() != null) {
        crit.add(Restrictions.le("history.date", filterModel.getEndDate()));
    }

    if (filterModel.getLastStatus() != null) {
        crit.add(Restrictions.eq("lastStatus", filterModel.getLastStatus()));
        crit.add(Restrictions.ne("previousStatus", filterModel.getLastStatus()));
    }

    if (getIsClientPromissory() != null) {
        crit.add(Restrictions.eq("clientPromissoryNote", getIsClientPromissory()));
    }

    crit.add(Restrictions.eqProperty("history.status", "this.lastStatus"));

    return crit;
}

From source file:com.ut.tekir.invoice.yeni.LimitationChecker.java

License:LGPL

public DetachedCriteria buildCriteriaForWarehouse() {

    DetachedCriteria crit = DetachedCriteria.forClass(ProductTxn.class);

    crit.createAlias("product", "product");
    crit.createAlias("warehouse", "warehouse");

    ProjectionList pl = Projections.projectionList();
    pl.add(Projections.groupProperty("product.code"), "prodcode")
            .add(Projections.groupProperty("product.name"), "prodname")
            .add(Projections.groupProperty("product.group"), "group")
            .add(Projections.groupProperty("product.barcode1"), "barcode")
            .add(Projections.groupProperty("warehouse.code"), "warecode")
            .add(Projections.groupProperty("warehouse.name"), "warename")
            .add(Projections.sum("quantity.value"), "quantity")
            .add(Projections.avg("unitPrice.value"), "unitPrice")
            .add(Projections.sqlGroupProjection("{alias}.UNIT as unit, "
                    + "sum( case {alias}.trade_action when 0 then {alias}.QUANTITY else 0 end ) as INQTY, "
                    + "sum( case {alias}.trade_action when 1 then {alias}.QUANTITY else 0 end ) as OUTQTY , "
                    + "sum( case {alias}.trade_action when 2 then {alias}.QUANTITY else 0 end ) as BUYRETQTY, "
                    + "sum( case {alias}.trade_action when 3 then {alias}.QUANTITY else 0 end ) as SELLRETQTY, "
                    + "sum( case {alias}.trade_action when 6 then {alias}.QUANTITY else 0 end ) as RESQTY , "
                    + "sum( case {alias}.trade_action when 7 then {alias}.QUANTITY else 0 end ) as DELQTY ",
                    "UNIT",
                    new String[] { "unit", "inqty", "outqty", "buyretqty", "sellretqty", "resqty", "delqty" },
                    new Type[] { Hibernate.STRING, Hibernate.DOUBLE, Hibernate.DOUBLE, Hibernate.DOUBLE,
                            Hibernate.DOUBLE, Hibernate.DOUBLE, Hibernate.DOUBLE }));

    crit.setProjection(pl);//from w w  w  .  ja va2  s . com

    crit.add(Restrictions.eq("active", true));

    //Evran kendisini toplam deerlere eklemiyoruz.
    if (filterModel.getDocId() != null) {
        crit.add(Restrictions.ne("documentId", filterModel.getDocId()));
    }

    if (filterModel.getBarcode() != null && filterModel.getBarcode().length() > 0) {
        Criterion criteria1 = Restrictions.eq("product.barcode1", filterModel.getBarcode());
        Criterion criteria2 = Restrictions.eq("product.barcode2", filterModel.getBarcode());
        Criterion criteria3 = Restrictions.eq("product.barcode3", filterModel.getBarcode());

        crit.add(Restrictions.or(criteria1, Restrictions.or(criteria2, criteria3)));
    }

    if (filterModel.getProduct() != null) {
        crit.add(Restrictions.eq("product", filterModel.getProduct()));
    }
    crit.addOrder(Order.asc("product.name"));

    return crit;
}

From source file:com.viettel.vsaadmin.database.DAO.UsersDAO.java

License:Open Source License

/**
 * Khoi tao du lieu tim kiem/*from   w w w.ja  v  a2s.  co  m*/
 *
 * @return
 */
public String onInit() {
    try {
        Session session = getSession();
        Criteria cri = session.createCriteria(Users.class);
        cri.add(Restrictions.ne("status", Long.valueOf(-1L)));
        List lst = cri.list();

        this.jsonDataGrid.setItems(lst);
    } catch (Exception ex) {
        LogUtil.addLog(ex);//binhnt sonar a160901
        //            log.error(ex.getMessage());
    }
    return "gridData";
}

From source file:com.vmware.appfactory.application.dao.ApplicationDaoImpl.java

License:Open Source License

/**
 * Get all other applications that match the passed app name and are marked
 * for inclusion./* w w  w  .  j  av a  2 s .  c om*/
 *
 * @param app
 * @return
 */
@Override
public List<Application> findOtherVersionsIncluded(Application app) {
    Criterion c1 = Restrictions.eq("_name", app.getName()).ignoreCase();
    Criterion c2 = Restrictions.ne("_id", app.getId());
    Criterion c3 = Restrictions.eq("_skipped", false);
    return findByCriterion(Restrictions.and(Restrictions.and(c1, c2), c3));
}

From source file:com.vmware.appfactory.feed.dao.FeedDaoImpl.java

License:Open Source License

@Override
public long countFailed() {
    Criterion criterion = Restrictions.and(Restrictions.isNotNull("_failure._summary"),
            Restrictions.ne("_failure._summary", Feed.SCANNING));
    return countByCriterion(criterion);
}

From source file:com.vmware.bdd.entity.TaskEntity.java

License:Open Source License

public static List<TaskEntity> findAllByStatus(final Status[] anyStatus, final String exceptCookie) {
    return DAL.autoTransactionDo(new Saveable<List<TaskEntity>>() {
        @Override/*from   ww w . j  a v a  2  s.co m*/
        public List<TaskEntity> body() throws Exception {
            Criterion crit = null;
            for (Status s : anyStatus) {
                if (crit == null) {
                    crit = Restrictions.eq("status", s);
                } else {
                    crit = Restrictions.or(crit, Restrictions.eq("status", s));
                }
            }

            AuAssert.check(crit != null);

            if (exceptCookie != null) {
                crit = Restrictions.and(crit, Restrictions.ne("cookie", exceptCookie));
            }

            return DAL.findByCriteria(TaskEntity.class, crit);
        }
    });
}

From source file:com.webbfontaine.valuewebb.action.pricedb.pdss.PdssSearch.java

License:Open Source License

@Override
protected Criteria constructCriteria() throws Exception {
    PdssCriteriaContainer criteriaContainer = (PdssCriteriaContainer) getCriteriaContainer();

    criteriaContainer.setEntityClass(Pd.class);
    criteriaContainer.setFakeToRealPropertyMap(PropertyMapProvider.forClass(Pd.class));

    pdCriteria = criteriaContainer.transformUserCriteria(PersistenceUtil.getSession(Utils.getEntityManager()));
    //        pdCriteria.addOrder(Order.desc("id"));
    pdCriteria.setMaxResults(Constants.MAX_RECORDS_IN_ATTACHED_FINDER);
    pdCriteria.add(Restrictions.ne("id", pdId));

    criteriaContainer.setEntityClass(MarketPrice.class);
    criteriaContainer.setFakeToRealPropertyMap(PropertyMapProvider.forClass(MarketPrice.class));

    mpCriteria = criteriaContainer.transformUserCriteria(PersistenceUtil.getSession(Utils.getEntityManager()));
    //        mpCriteria.addOrder(Order.desc("id"));
    mpCriteria.setMaxResults(Constants.MAX_RECORDS_IN_ATTACHED_FINDER);

    return null;//from  www.j  a  v a2s.com
}

From source file:com.webbfontaine.valuewebb.search.custom.UserCriterion.java

License:Open Source License

public Criterion getCriterion() throws Exception {
    if (condition.equals(EQ)) {
        if (value == null || value.toString().trim().length() == 0) {
            return Restrictions.isNull(fullKey);
        } else {//w  w  w  .ja  v a2 s .  com
            return Restrictions.eq(fullKey, value);
        }
    }

    if (condition.equals(NE)) {
        if (value == null || value.toString().trim().length() == 0) {
            return Restrictions.isNotNull(fullKey);
        } else {
            return Restrictions.ne(fullKey, value);
        }
    }

    if (condition.equals(GT)) {
        assertNonNullity(value);
        return Restrictions.gt(fullKey, value);
    }

    if (condition.equals(GE)) {
        assertNonNullity(value);
        return Restrictions.ge(fullKey, value);
    }

    if (condition.equals(LT)) {
        assertNonNullity(value);
        return Restrictions.lt(fullKey, value);
    }

    if (condition.equals(LE)) {
        assertNonNullity(value);
        return Restrictions.le(fullKey, value);
    }

    if (condition.equals(IN_A_RANGE)) {
        assertNonNullity(value);
        assertNonNullity(diff);
        return getPercentRange();
    }

    if (condition.equals(ENDS_WITH)) {
        return Restrictions.like(fullKey, "%" + StringUtils.trim(value.toString()));
    }

    if (condition.equals(STARTS_WITH)) {
        return Restrictions.like(fullKey, StringUtils.trim(value.toString()) + "%");
    }

    if (condition.equals(CONTAINS)) {
        return Restrictions.like(fullKey, "%" + StringUtils.trim(value.toString()) + '%');
    }

    if (condition.equals(NOT_CONTAIN)) {
        return Restrictions.not(Restrictions.like(fullKey, "%" + StringUtils.trim(value.toString()) + '%'));
    }

    LOGGER.error(
            "Undefined User Criteria [key:{0}, value:{1}, condition:{3}] couldn't be transformed to search criterion",
            fullKey, value, condition);

    throw new RuntimeException("Undefined User Criteria: " + name);
}

From source file:com.wooki.domain.dao.ActivityDAOImpl.java

License:Apache License

public List<Activity> listCoauthorBookActivity(Long userId, QueryFilter... filters) {
    assert userId != null;

    Criteria crit = session.createCriteria(AbstractBookActivity.class);
    crit.add(Restrictions.ne("user.id", userId)).createCriteria("book").createAlias("users", "u")
            .add(Restrictions.eq("u.id", userId));
    applyFilters(crit, filters);//from   w  w w.  j ava2 s  .  c o m
    return crit.list();
}