package com.rjconsultores.ventaboletos.dao.hibernate; 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.SeguradoraEmpresaDAO; import com.rjconsultores.ventaboletos.entidad.Empresa; import com.rjconsultores.ventaboletos.entidad.SeguradoraEmpresa; @Repository("seguradoraEmpresaDAO") public class SeguradoraEmpresaHibernateDAO extends GenericHibernateDAO implements SeguradoraEmpresaDAO { @Autowired public SeguradoraEmpresaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { setSessionFactory(factory); } public List obtenerTodos() { Criteria c = makeCriteria(); c.add(Restrictions.eq("activo", Boolean.TRUE)); return c.list(); } public boolean existe(Empresa empresa){ Criteria c = makeCriteria(); c.add(Restrictions.eq("activo", Boolean.TRUE)); c.add(Restrictions.eq("empresa", empresa)); return !c.list().isEmpty(); } }