AdmMono/src/com/rjconsultores/ventaboletos/dao/hibernate/ParamAcumulaPuntoHibernateD...

53 lines
1.6 KiB
Java

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.rjconsultores.ventaboletos.dao.hibernate;
import com.rjconsultores.ventaboletos.dao.ParamAcumulaPuntoDAO;
import com.rjconsultores.ventaboletos.entidad.Parada;
import com.rjconsultores.ventaboletos.entidad.ParamAcumulaPunto;
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;
/**
*
* @author Rafius
*/
@Repository("paramAcumulaPuntoDAO")
public class ParamAcumulaPuntoHibernateDAO extends GenericHibernateDAO<ParamAcumulaPunto, Integer>
implements ParamAcumulaPuntoDAO {
@Autowired
public ParamAcumulaPuntoHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
setSessionFactory(factory);
}
public List<ParamAcumulaPunto> buscar(Parada origem, Parada destino, Date ini, Date fim) {
Criteria c = getSession().createCriteria(getPersistentClass());
c.add(Restrictions.eq("activo", Boolean.TRUE));
if (origem != null) {
c.add(Restrictions.eq("origem", origem));
}
if (destino != null) {
c.add(Restrictions.eq("destino", destino));
}
if (ini != null) {
c.add(Restrictions.ge("feciniciovigencia", ini));
}
if (fim != null) {
c.add(Restrictions.le("fecfinvigencia", fim));
}
return c.list();
}
}