39 lines
1.3 KiB
Java
39 lines
1.3 KiB
Java
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<SeguradoraEmpresa, Integer> implements SeguradoraEmpresaDAO {
|
|
|
|
@Autowired
|
|
public SeguradoraEmpresaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
|
setSessionFactory(factory);
|
|
}
|
|
|
|
public List<SeguradoraEmpresa> 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();
|
|
}
|
|
}
|