/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package com.rjconsultores.ventaboletos.dao.hibernate; import java.util.Date; import java.util.List; import org.hibernate.Criteria; import org.hibernate.SessionFactory; import org.hibernate.criterion.Restrictions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Repository; import com.rjconsultores.ventaboletos.dao.ParamAcumulaMasivoDAO; import com.rjconsultores.ventaboletos.entidad.Empresa; import com.rjconsultores.ventaboletos.entidad.ParamAcumulaMasivo; /** * * @author Rafius */ @Repository("paramAcumulaMasivoDAO") public class ParamAcumulaMasivoHibernateDAO extends GenericHibernateDAO implements ParamAcumulaMasivoDAO { @Autowired public ParamAcumulaMasivoHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { setSessionFactory(factory); } @Override public List buscar(Empresa emp, Integer min, Integer max, Date fecIni, Date fecFim) { Criteria c = getSession().createCriteria(getPersistentClass()); c.add(Restrictions.eq("activo", Boolean.TRUE)); if (emp != null) { c.add(Restrictions.eq("empresa", emp)); } if (min != null) { c.add(Restrictions.ge("minpuntootorga", min)); } if (max != null) { c.add(Restrictions.le("maxpuntootorga", max)); } if (fecIni != null) { c.add(Restrictions.ge("feciniciovigencia", fecIni)); } if (fecFim != null) { c.add(Restrictions.le("fecfinvigencia", fecFim)); } return c.list(); } @Override public List buscar(ParamAcumulaMasivo paramAcumulaMasivo) { Criteria c = this.getSession().createCriteria(ParamAcumulaMasivo.class); c.add(Restrictions.eq("activo", Boolean.TRUE)); c.add(Restrictions.ge("fecfinvigencia", paramAcumulaMasivo.getFeciniciovigencia())); c.add(Restrictions.le("feciniciovigencia", paramAcumulaMasivo.getFecfinvigencia())); c.add(Restrictions.eq("empresa", paramAcumulaMasivo.getEmpresa())); return c.list(); } }