/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package com.rjconsultores.ventaboletos.dao.hibernate; import java.util.List; import org.hibernate.Query; import org.hibernate.SessionFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Repository; import com.rjconsultores.ventaboletos.dao.EmpresaImpostoDAO; import com.rjconsultores.ventaboletos.entidad.Empresa; import com.rjconsultores.ventaboletos.entidad.EmpresaImposto; /** * * @author Bruno H. G. Gouvêa * */ @Repository("empresaImpostoDAO") public class EmpresaImpostoHibernateDAO extends GenericHibernateDAO implements EmpresaImpostoDAO { @Autowired public EmpresaImpostoHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { setSessionFactory(factory); } @SuppressWarnings("unchecked") @Override public List buscarEmpresaImposto(Integer empresaId) { StringBuilder hql = new StringBuilder(); hql.append(" from EmpresaImposto ei "); hql.append(" where ei.activo = 1 "); hql.append(" AND ei.empresa.empresaId = :empresaId "); Query query = getSession().createQuery(hql.toString()); query.setInteger("empresaId", empresaId); return query.list(); } @Override public List buscarByEmpresa(Empresa empresa) { return buscarEmpresaImposto(empresa.getEmpresaId()); } }