/* * 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.ExcepcionRedondoDAO; import com.rjconsultores.ventaboletos.entidad.ExcepcionRedondo; import com.rjconsultores.ventaboletos.entidad.Parada; import java.util.List; import org.hibernate.Criteria; import org.hibernate.SessionFactory; import org.hibernate.criterion.Order; 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 Administrador */ @Repository("excepcionRedondoDAO") public class ExcepcionRedondoHibernateDAO extends GenericHibernateDAO implements ExcepcionRedondoDAO { @Autowired public ExcepcionRedondoHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { setSessionFactory(factory); } @Override public List obtenerTodos() { Criteria c = getSession().createCriteria(getPersistentClass()); c.add(Restrictions.eq("activo", Boolean.TRUE)); c.addOrder(Order.asc("indtipo")); return c.list(); } public List buscar(String indTipo, Parada origem, Parada destino) { Criteria c = getSession().createCriteria(getPersistentClass()); c.add(Restrictions.eq("activo", Boolean.TRUE)); c.add(Restrictions.eq("origem", origem)); c.add(Restrictions.eq("destino", destino)); c.add(Restrictions.eq("indtipo", indTipo)); c.addOrder(Order.asc("indtipo")); return c.list(); } @Override public List buscar(Parada origem, Parada destino) { Criteria c = getSession().createCriteria(getPersistentClass()); c.add(Restrictions.eq("activo", Boolean.TRUE)); c.add(Restrictions.eq("origem", origem)); c.add(Restrictions.eq("destino", destino)); return c.list(); } }