Example usage for org.hibernate.criterion Restrictions ge

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

Introduction

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

Prototype

public static SimpleExpression ge(String propertyName, Object value) 

Source Link

Document

Apply a "greater than or equal" constraint to the named property

Usage

From source file:cn.com.jandar.lawyer.service.LawFirmService.java

@SuppressWarnings("unchecked")
public List<LawFirm> findByParam(Date lastUpdateDate, Integer pageNum, Integer pageSize) {
    Criteria c = lawFirmDao.getSession().createCriteria(LawFirm.class);
    if (lastUpdateDate != null) {
        c.add(Restrictions.ge("lastUpdateDate", lastUpdateDate));
    }//from   w ww  . j  a  v  a2 s  . c o  m
    c.setMaxResults(pageSize);
    c.setFirstResult(pageNum * pageSize + 1);
    c.addOrder(Order.desc("laseUpdateDate"));
    return c.list();
}

From source file:cn.com.jandar.lawyer.service.LawFirmService.java

/**
 * ??//from w  w  w  . j a  v  a2 s .c o m
 * @param lastUpdateDate
 * @return
 */
@SuppressWarnings("unchecked")
public List<LawFirm> findByLastUpdateDate(Date lastUpdateDate) {
    Criteria c = lawFirmDao.getSession().createCriteria(LawFirm.class);
    c.add(Restrictions.ge("lastUpdateDate", lastUpdateDate));
    return c.list();
}

From source file:cn.com.jandar.lawyer.service.LawyerService.java

/**
 * ??/*from w w  w.  j a v  a  2s .c om*/
 * @param lastUpdateDate
 * @return
 */
@SuppressWarnings("unchecked")
public List<Lawyer> findByLastUpdateDate(Date lastUpdateDate) {
    Criteria c = lawyerDao.getSession().createCriteria(Lawyer.class);
    c.add(Restrictions.ge("lastUpdateDate", lastUpdateDate));
    return c.list();
}

From source file:cn.com.jandar.lawyer.service.LawyerService.java

/**
 * ?/*w w w.  j  a v a  2s  .  c  o  m*/
 * @param lastUpdateDate
 * @param pageNum
 * @param pageSize
 * @return
 */
@SuppressWarnings("unchecked")
public List<Lawyer> findByParam(Date lastUpdateDate, Integer pageNum, Integer pageSize) {
    Criteria c = lawyerDao.getSession().createCriteria(Lawyer.class);
    if (lastUpdateDate != null) {
        c.add(Restrictions.ge("lastUpdateDate", lastUpdateDate));
    }
    c.setMaxResults(pageSize);
    c.setFirstResult(pageNum * pageSize + 1);
    c.addOrder(Order.desc("laseUpdateDate"));
    return c.list();
}

From source file:cn.hxh.springside.orm.hibernate.HibernateDao.java

License:Apache License

/**
 * ??Criterion,./*  w ww.j  a v  a2 s .c om*/
 */
protected Criterion buildCriterion(final String propertyName, final Object propertyValue,
        final MatchType matchType) {
    AssertUtils.hasText(propertyName, "propertyName?");
    Criterion criterion = null;
    //?MatchTypecriterion
    switch (matchType) {
    case EQ:
        criterion = Restrictions.eq(propertyName, propertyValue);
        break;
    case LIKE:
        criterion = Restrictions.like(propertyName, (String) propertyValue, MatchMode.ANYWHERE);
        break;

    case LE:
        criterion = Restrictions.le(propertyName, propertyValue);
        break;
    case LT:
        criterion = Restrictions.lt(propertyName, propertyValue);
        break;
    case GE:
        criterion = Restrictions.ge(propertyName, propertyValue);
        break;
    case GT:
        criterion = Restrictions.gt(propertyName, propertyValue);
    }
    return criterion;
}

From source file:cn.newtouch.hibernate.dao.StudentDAO.java

License:Open Source License

public static void main(String[] args) {
    try {/* w  w  w. j  a  v  a  2s  .  c o  m*/
        Session session = HibernateUtil.getSession();
        String hql = " from Student";
        List<Student> userList = session.createQuery(hql).list();
        System.out.println("=====1=======" + userList.size());
        Criteria criteria = session.createCriteria(Student.class);
        // 
        criteria.add(Restrictions.eq("name", "HZZ"));
        // map
        criteria.add(Restrictions.allEq(new HashMap<String, String>()));
        // 
        criteria.add(Restrictions.gt("id", new Long(1)));
        // 
        criteria.add(Restrictions.ge("id", new Long(1)));
        // ?
        criteria.add(Restrictions.lt("id", new Long(1)));
        // ?
        criteria.add(Restrictions.le("id", new Long(1)));
        // xxxyyy
        criteria.add(Restrictions.between("id", new Long(1), new Long(2)));
        // ?
        criteria.add(Restrictions.like("name", "H"));
        // and?
        criteria.add(Restrictions.and(Restrictions.ge("id", new Long(1)), Restrictions.ge("id", new Long(1))));
        // or?
        criteria.add(Restrictions.or(Restrictions.ge("id", new Long(1)), Restrictions.ge("id", new Long(1))));
        userList = criteria.list();
        System.out.println("=====2=======" + userList.size());
        Student student = new Student();
        student.setId(123456L);
        student.setName("hzz");
        student.setAge(14);
        save(student);

        System.out.println("OK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");

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

    }
}

From source file:cn.newtouch.util.hibernate.HibernateDao.java

License:Apache License

/**
 * ??Criterion,./*from   w ww  .  ja  v  a2 s  .co m*/
 */
protected Criterion buildCriterion(final String propertyName, final Object propertyValue,
        final MatchType matchType) {
    Assert.hasText(propertyName, "propertyName?");
    Criterion criterion = null;
    // ?MatchTypecriterion
    switch (matchType) {
    case EQ:
        criterion = Restrictions.eq(propertyName, propertyValue);
        break;
    case LIKE:
        criterion = Restrictions.like(propertyName, (String) propertyValue, MatchMode.ANYWHERE);
        break;

    case LE:
        criterion = Restrictions.le(propertyName, propertyValue);
        break;
    case LT:
        criterion = Restrictions.lt(propertyName, propertyValue);
        break;
    case GE:
        criterion = Restrictions.ge(propertyName, propertyValue);
        break;
    case GT:
        criterion = Restrictions.gt(propertyName, propertyValue);
    }
    return criterion;
}

From source file:cn.newtouch.util.orm.hibernate.HibernateDao.java

License:Apache License

/**
 * ??Criterion,.//w  w w  .  j  a v a 2 s .c om
 */
protected Criterion buildCriterion(final String propertyName, final Object propertyValue,
        final MatchType matchType) {
    Assert.hasText(propertyName, "propertyName?");
    Criterion criterion = null;
    //?MatchTypecriterion
    switch (matchType) {
    case EQ:
        criterion = Restrictions.eq(propertyName, propertyValue);
        break;
    case LIKE:
        criterion = Restrictions.like(propertyName, (String) propertyValue, MatchMode.ANYWHERE);
        break;

    case LE:
        criterion = Restrictions.le(propertyName, propertyValue);
        break;
    case LT:
        criterion = Restrictions.lt(propertyName, propertyValue);
        break;
    case GE:
        criterion = Restrictions.ge(propertyName, propertyValue);
        break;
    case GT:
        criterion = Restrictions.gt(propertyName, propertyValue);
    }
    return criterion;
}

From source file:cn.trymore.oa.service.system.impl.ServiceSystemLogImpl.java

License:Open Source License

@Override
public PaginationSupport<ModelSystemLog> getPaginationByEntity(ModelSystemLog entity, PagingBean pagingBean)
        throws ServiceException {
    DetachedCriteria criteria = DetachedCriteria.forClass(ModelSystemLog.class);

    if (entity != null) {
        if (UtilString.isNotEmpty(entity.getExeOperation())) {
            criteria.add(Restrictions.eq("exeOperation", entity.getExeOperation()));
        }/* w  w  w.j a  v  a 2 s .  c om*/

        if (entity.getDistrictId() != null && UtilString.isNotEmpty(entity.getDistrictId())) {
            criteria.createCriteria("user").createCriteria("district")
                    .add(Restrictions.eq("id", entity.getDistrictId()));
        }

        if (entity.getStartTime() != null && UtilString.isNotEmpty(entity.getStartTime())) {
            criteria.add(Restrictions.ge("createtime", entity.getStartTime()));
        }

        if (entity.getEndTime() != null && UtilString.isNotEmpty(entity.getEndTime())) {
            criteria.add(Restrictions.le("createtime", entity.getEndTime()));
        }
    }

    // added by Jeccy.Zhao on 14/10/2012
    criteria.addOrder(Order.desc("createtime"));

    return this.getAll(criteria, pagingBean);
}

From source file:co.com.codesoftware.logic.ProductoLogic.java

/**
 * funcion que consulta las facturas por filtros
 *
 * @param idProveedor//from  www  . java  2 s  .co m
 * @param fechaInicial
 * @param fechaFinal
 * @param estado
 * @param imagen
 * @return
 */
public List<FacturaCompraTotalEntity> consultaFacturas(Integer idProveedor, Date fechaInicial, Date fechaFinal,
        String estado, String imagen, String digitalizado) {
    List<FacturaCompraTotalEntity> lista = null;
    try {
        initOperation();
        Criteria criteria = sesion.createCriteria(FacturaCompraTotalEntity.class).setFetchMode("proveedor",
                FetchMode.JOIN);
        if (idProveedor != -1) {
            criteria.createAlias("proveedor", "pr").add(Restrictions.eq("pr.id", idProveedor));
        }
        if (fechaInicial != null && fechaFinal != null) {
            criteria.add(Restrictions.ge("fechaCreacion", fechaInicial));
            criteria.add(Restrictions.lt("fechaCreacion", fechaFinal));
        }
        if (estado != null && "".equalsIgnoreCase(estado) && "-1".equalsIgnoreCase(estado)) {
            criteria.add(Restrictions.eq("estado", estado));
        }
        if (imagen != null && "".equalsIgnoreCase(imagen) && "-1".equalsIgnoreCase(imagen)) {
            criteria.add(Restrictions.eq("rutaImagen", imagen));
        }
        if ("S".equalsIgnoreCase(digitalizado)) {
            criteria.add(Restrictions
                    .sqlRestriction(" exists (select 1 from fa_timfac where imfac_facom = facom_facom) "));
        } else if ("N".equalsIgnoreCase(digitalizado)) {
            criteria.add(Restrictions
                    .sqlRestriction(" not exists (select 1 from fa_timfac where imfac_facom = facom_facom) "));
        }
        lista = criteria.list();

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