Example usage for org.hibernate Criteria addOrder

List of usage examples for org.hibernate Criteria addOrder

Introduction

In this page you can find the example usage for org.hibernate Criteria addOrder.

Prototype

public Criteria addOrder(Order order);

Source Link

Document

Add an Order ordering to the result set.

Usage

From source file:com.ar.dev.tierra.api.dao.impl.DetalleNotaCreditoDAOImpl.java

@SuppressWarnings("unchecked")
@Override/*from   w  ww.j  a v  a 2 s.  c  om*/
public List<DetalleNotaCredito> getByNotaCredito(int idNotaCredito) {
    Criteria criteria = getSession().createCriteria(DetalleNotaCredito.class);
    Criteria notaCredito = criteria.createCriteria("notaCredito");
    notaCredito.add(Restrictions.eq("idNotaCredito", idNotaCredito));
    criteria.addOrder(Order.desc("idDetalleNotaCredito"));
    List<DetalleNotaCredito> list = criteria.list();
    return list;
}

From source file:com.ar.dev.tierra.api.dao.impl.DetalleTransferenciaDAOimpl.java

@SuppressWarnings("unchecked")
@Override/*  w w w .j a  va  2s .com*/
public List<DetalleTransferencia> getAll() {
    Criteria criteria = getSession().createCriteria(DetalleTransferencia.class);
    criteria.addOrder(Order.desc("idDetalleTransferencia"));
    List<DetalleTransferencia> list = criteria.list();
    return list;
}

From source file:com.ar.dev.tierra.api.dao.impl.DetalleTransferenciaDAOimpl.java

@Override
public List<DetalleTransferencia> getDaily() {
    Criteria criteria = getSession().createCriteria(DetalleTransferencia.class);
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    Date fromDate = calendar.getTime();
    calendar.set(Calendar.HOUR_OF_DAY, 23);
    calendar.set(Calendar.MINUTE, 59);
    calendar.set(Calendar.SECOND, 59);
    Date toDate = calendar.getTime();
    criteria.add(Restrictions.between("fechaCreacion", fromDate, toDate));
    criteria.addOrder(Order.desc("idDetalleTransferencia"));
    List<DetalleTransferencia> list = criteria.list();
    return list;/*w w  w. j  a  v a 2  s. c  o  m*/
}

From source file:com.ar.dev.tierra.api.dao.impl.DetalleTransferenciaDAOimpl.java

@Override
public List<DetalleTransferencia> getMonth() {
    Criteria criteria = getSession().createCriteria(DetalleTransferencia.class);
    Calendar calendar = Calendar.getInstance();
    Date toDate = calendar.getTime();
    calendar.add(Calendar.MONTH, -1);
    Date fromDate = calendar.getTime();
    criteria.add(Restrictions.between("fechaCreacion", fromDate, toDate));
    criteria.addOrder(Order.desc("idDetalleTransferencia"));
    List<DetalleTransferencia> list = criteria.list();
    return list;//from   w  w  w  . j av a 2  s  . co  m
}

From source file:com.ar.dev.tierra.api.dao.impl.DetalleTransferenciaDAOimpl.java

@Override
@SuppressWarnings("null")
public List<WrapperStock> findByParams(String descripcion, String marca, String talla, String codigo,
        String categoria, int sucursal) {
    Criteria criteria = null;
    switch (sucursal) {
    case 1:/*w ww  .  j av  a  2 s .  c  o m*/
        criteria = getSession().createCriteria(StockTierra.class);
        break;
    case 2:
        criteria = getSession().createCriteria(StockBebelandia.class);
        break;
    case 3:
        criteria = getSession().createCriteria(StockLibertador.class);
        break;
    }
    criteria.add(Restrictions.eq("estado", true));
    criteria.addOrder(Order.asc("idStock"));
    Criteria producto = criteria.createCriteria("idProducto");
    if (!descripcion.equals("")) {
        producto.add(Restrictions.ilike("descripcion", descripcion, MatchMode.START));
    }
    if (!marca.equals("")) {
        Criteria marcas = producto.createCriteria("marcas");
        marcas.add(Restrictions.ilike("nombreMarca", marca, MatchMode.START));
    }
    if (!talla.equals("")) {
        producto.add(Restrictions.ilike("talla", talla, MatchMode.START));
    }
    if (!codigo.equals("")) {
        producto.add(Restrictions.ilike("codigoProducto", codigo, MatchMode.START));
    }
    if (!categoria.equals("")) {
        Criteria categorias = producto.createCriteria("categoria");
        categorias.add(Restrictions.ilike("nombreCategoria", categoria, MatchMode.START));
    }
    List<WrapperStock> list = new ArrayList<>();
    switch (sucursal) {
    case 1:
        List<StockTierra> tierraList = criteria.list();
        for (StockTierra stockTierra : tierraList) {
            WrapperStock wrapperTierra = new WrapperStock();
            wrapperTierra.setStockTierra(stockTierra);
            list.add(wrapperTierra);
        }
        break;
    case 2:
        List<StockBebelandia> bebeList = criteria.list();
        for (StockBebelandia stockBebelandia : bebeList) {
            WrapperStock wrapperBebelandia = new WrapperStock();
            wrapperBebelandia.setStockBebelandia(stockBebelandia);
            list.add(wrapperBebelandia);
        }
        break;
    case 3:
        List<StockLibertador> libertadorList = criteria.list();
        for (StockLibertador stockLibertador : libertadorList) {
            WrapperStock wrapperLibertador = new WrapperStock();
            wrapperLibertador.setStockLibertador(stockLibertador);
            list.add(wrapperLibertador);
        }
        break;
    }
    return list;
}

From source file:com.ar.dev.tierra.api.dao.impl.EntidadBancariaDAOImpl.java

@SuppressWarnings("unchecked")
@Override/*  www  .  j  a v  a2s  . com*/
public List<EntidadBancaria> getAll() {
    Criteria criteria = getSession().createCriteria(EntidadBancaria.class);
    criteria.add(Restrictions.eq("estadoEntidad", true));
    criteria.addOrder(Order.asc("idEntidadMonetaria"));
    List<EntidadBancaria> list = criteria.list();
    return list;
}

From source file:com.ar.dev.tierra.api.dao.impl.FacturaDAOImpl.java

@Override
public List<Factura> getDiary() {
    Criteria criteria = getSession().createCriteria(Factura.class);
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    Date fromDate = calendar.getTime();
    calendar.set(Calendar.HOUR_OF_DAY, 23);
    calendar.set(Calendar.MINUTE, 59);
    calendar.set(Calendar.SECOND, 59);
    Date toDate = calendar.getTime();
    criteria.add(Restrictions.between("fechaCreacion", fromDate, toDate));
    criteria.addOrder(Order.asc("idFactura"));
    criteria.add(Restrictions.not(Restrictions.in("estado", new String[] { "RESERVADO" })));
    criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
    criteria.addOrder(Order.desc("idFactura"));
    List<Factura> list = criteria.list();
    return list;//from w  ww . j a  v  a 2  s . c o m
}

From source file:com.ar.dev.tierra.api.dao.impl.FacturaDAOImpl.java

@Override
public List<Factura> getMonth() {
    Criteria criteria = getSession().createCriteria(Factura.class);
    Calendar calendar = Calendar.getInstance();
    Date toDate = calendar.getTime();
    calendar.add(Calendar.MONTH, -1);
    Date fromDate = calendar.getTime();
    criteria.add(Restrictions.between("fechaCreacion", fromDate, toDate));
    criteria.add(Restrictions.not(Restrictions.in("estado", new String[] { "RESERVADO" })));
    criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
    criteria.addOrder(Order.desc("idFactura"));
    List<Factura> list = criteria.list();
    return list;/*from ww  w. j a  va  2s  .c  om*/
}

From source file:com.ar.dev.tierra.api.dao.impl.FacturaDAOImpl.java

@Override
public List<Factura> getDiaryReserva() {
    Criteria criteria = getSession().createCriteria(Factura.class);
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    Date fromDate = calendar.getTime();
    calendar.set(Calendar.HOUR_OF_DAY, 23);
    calendar.set(Calendar.MINUTE, 59);
    calendar.set(Calendar.SECOND, 59);
    Date toDate = calendar.getTime();
    criteria.add(Restrictions.between("fechaCreacion", fromDate, toDate));
    criteria.addOrder(Order.desc("idFactura"));
    criteria.add(Restrictions// w  ww  . j  ava  2s  .  com
            .not(Restrictions.in("estado", new String[] { "INICIADO", "CONFIRMADO", "CANCELADO" })));
    criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
    List<Factura> list = criteria.list();
    return list;
}

From source file:com.ar.dev.tierra.api.dao.impl.FacturaDAOImpl.java

@Override
public List<Factura> getMonthReserva() {
    Criteria criteria = getSession().createCriteria(Factura.class);
    Calendar calendar = Calendar.getInstance();
    Date toDate = calendar.getTime();
    calendar.add(Calendar.MONTH, -1);
    Date fromDate = calendar.getTime();
    criteria.add(Restrictions.between("fechaCreacion", fromDate, toDate));
    criteria.add(Restrictions/*  w  w  w .j  a v a  2s  .c  o  m*/
            .not(Restrictions.in("estado", new String[] { "INICIADO", "CONFIRMADO", "CANCELADO" })));
    criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
    criteria.addOrder(Order.desc("idFactura"));
    List<Factura> list = criteria.list();
    return list;
}