Example usage for org.hibernate.criterion Restrictions gt

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

Introduction

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

Prototype

public static SimpleExpression gt(String propertyName, Object value) 

Source Link

Document

Apply a "greater than" constraint to the named property

Usage

From source file:com.scopix.periscope.extractionplanmanagement.EServerDAO.java

License:Open Source License

public ExtractionPlan getExtractionPlanForADate(Date date) {
    ExtractionPlan extractionPlan = null;
    Criteria criteria = this.getSession().createCriteria(ExtractionPlan.class);
    criteria.addOrder(Order.asc("expirationDate"));
    criteria.add(Restrictions.isNotNull("expirationDate"));
    criteria.add(Restrictions.gt("expirationDate", date));
    List<ExtractionPlan> eps = criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list();
    if (eps != null && !eps.isEmpty()) {
        extractionPlan = (ExtractionPlan) eps.get(0);
    }/*from  ww  w .  j  a va2  s  .co  m*/
    return extractionPlan;
}

From source file:com.scopix.periscope.extractionplanmanagement.EServerDAO.java

License:Open Source License

public List<ExtractionPlan> getExtractionPlanListForADate(Date date, String storeName) {
    Criteria criteria = this.getSession().createCriteria(ExtractionPlan.class);
    criteria.addOrder(Order.asc("expirationDate"));
    criteria.add(//from  w  ww  . ja  va 2s .c  o m
            Restrictions.or(Restrictions.isNull("expirationDate"), Restrictions.gt("expirationDate", date)));
    criteria.add(Restrictions.eq("storeName", storeName));
    List<ExtractionPlan> eps = criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list();
    return eps;
}

From source file:com.scopix.periscope.extractionservicesserversmanagement.dao.ExtractionPlanDetailDAO.java

License:Open Source License

public List<ExtractionPlan> getExtractionPlanByExpirationDate(Date dateStart) {

    Criteria criteria = this.getSession().createCriteria(ExtractionPlan.class);
    criteria.add(Restrictions.or(Restrictions.gt("expiration", dateStart), Restrictions.isNull("expiration")));
    criteria.addOrder(Order.asc("expiration"));
    List<ExtractionPlan> extractionPlans = criteria.list();
    return extractionPlans;
}

From source file:com.segundo.piso.daos.impl.DAOMovementImpl.java

@Override
@Transactional/*from w  w  w . ja v a 2 s.c  o  m*/
public List<Movimiento> getAvailableMovements(int idStudent, boolean active) {
    return this.sessionFactory.getCurrentSession().createCriteria(Movimiento.class, "movement")
            .createAlias("movement.idEvento", "event").createAlias("movement.idAlumno", "student")
            .add(Restrictions.eq("student.idAlumno", idStudent)).add(Restrictions.gt("event.diasMes", 0))
            .add(Restrictions.eq("movement.activo", active)).add(Restrictions.eq("movement.status", active))
            .addOrder(Order.asc("movement.fechaInicio")).list();
}

From source file:com.segundo.piso.daos.impl.DAOReportImpl.java

@Override
@Transactional/*from   w  ww  .j a v a2  s  .co m*/
public List<ReporteAlumno> getStudentsByExpiredMovement(int clasesRestantes) {
    System.out.println(sessionFactory);
    StringBuilder restriction = new StringBuilder();
    restriction.append("date_add(movimiento1_.fecha_inicio, interval 31 day) > curdate() ").append(
            "and date_add(movimiento1_.fecha_inicio, interval 31 day) < date_add(current_date(), interval 10 day)")
            .append("and movimiento1_.id_movimiento = asistencia2_.id_movimiento ");

    return this.sessionFactory.getCurrentSession().createCriteria(Alumno.class, "alumno")
            .createAlias("alumno.movimientoList", "movimiento")
            .createAlias("alumno.asistenciaList", "asistencia").createAlias("movimiento.idEvento", "evento")
            .setProjection(Projections.projectionList().add(Projections.property("alumno.codigo"), "codigo")
                    .add(Projections.property("alumno.nombre"), "nombre")
                    .add(Projections.min("asistencia.diasRestantes"), "clasesRestantes")
                    .add(Projections.max("movimiento.idMovimiento"))
                    .add(Projections.property("alumno.idAlumno"), "idAlumno")
                    .add(Projections.max("movimiento.fechaInicio"), "fecha")
                    .add(Projections.groupProperty("alumno.idAlumno")))
            .add(Restrictions.sqlRestriction(restriction.toString()))
            .add(Restrictions.eq("movimiento.activo", true)).add(Restrictions.gt("evento.diasMes", 1))
            .setResultTransformer(Transformers.aliasToBean(ReporteAlumno.class))
            .addOrder(Order.desc("asistencia.diasRestantes")).list();
}

From source file:com.segundo.piso.services.WorkshopService.java

public List<Taller> getWorkshopsByDate(Date date) {
    return daoWorkshop.getAllRecords(Taller.class, Restrictions.gt("fecha", date));
}

From source file:com.thinkmore.framework.orm.hibernate.HibernateDao.java

License:Apache License

/**
 * ??Criterion,./*  w  w  w . j  a  va2  s. c  o  m*/
 */
protected Criterion buildPropertyFilterCriterion(final String propertyName, final Object propertyValue,
        final MatchType matchType) {
    Assert.hasText(propertyName, "propertyName?");
    Criterion criterion = null;
    try {
        // ?MatchTypecriterion
        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 ReflectionUtil.convertReflectionExceptionToUnchecked(e);
    }
    return criterion;
}

From source file:com.tysanclan.site.projectewok.entities.dao.hibernate.ElectionDAOImpl.java

License:Open Source License

/**
 * @see com.tysanclan.site.projectewok.dataaccess.EwokHibernateDAO#createCriteria(com.tysanclan.site.projectewok.dataaccess.SearchFilter)
 *//*www. j a va2  s.co m*/
@Override
protected Criteria createCriteria(SearchFilter<Election> filter) {
    Criteria criteria = getSession().createCriteria(Election.class);

    if (filter instanceof ElectionFilter) {
        ElectionFilter ef = (ElectionFilter) filter;

        if (ef.getStartBefore() != null) {
            criteria.add(Restrictions.lt("start", ef.getStartBefore()));
        }
        if (ef.getStartAfter() != null) {
            criteria.add(Restrictions.gt("start", ef.getStartBefore()));
        }
    }

    return criteria;
}

From source file:com.tysanclan.site.projectewok.entities.dao.hibernate.PenaltyPointDAOImpl.java

License:Open Source License

@Override
protected Criteria createCriteria(SearchFilter<PenaltyPoint> filter) {
    Criteria criteria = getSession().createCriteria(PenaltyPoint.class);

    if (filter instanceof PenaltyPointFilter) {
        PenaltyPointFilter cf = (PenaltyPointFilter) filter;
        if (cf.getDateAfter() != null) {
            criteria.add(Restrictions.gt("given", cf.getDateAfter()));
        }//from w w w.  j  a  v  a  2 s.  c o  m
        if (cf.getUser() != null) {
            criteria.add(Restrictions.eq("user", cf.getUser()));
        }
    }

    return criteria;
}

From source file:com.tysanclan.site.projectewok.entities.dao.hibernate.RestTokenDAOImpl.java

License:Open Source License

@Override
protected Criteria createCriteria(SearchFilter<RestToken> filter) {
    Criteria criteria = getSession().createCriteria(RestToken.class);

    if (filter instanceof RestTokenFilter) {
        RestTokenFilter rtf = (RestTokenFilter) filter;

        if (rtf.getExpired() != null) {
            boolean expired = rtf.getExpired().booleanValue();

            if (expired) {
                criteria.add(Restrictions.lt("expires", System.currentTimeMillis()));
            } else {
                criteria.add(Restrictions.gt("expires", System.currentTimeMillis()));
            }/*from  w  w  w .j a  v  a 2s .c  om*/
        }

        if (rtf.getUser() != null) {
            criteria.add(Restrictions.eq("user", rtf.getUser()));
        }

        if (rtf.getHash() != null) {
            criteria.add(Restrictions.eq("hash", rtf.getHash()));
        }
    }

    return criteria;
}