54 lines
1.5 KiB
Java
54 lines
1.5 KiB
Java
/*
|
|
* 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 <bruno@rjconsultores.com.br>
|
|
*
|
|
*/
|
|
@Repository("empresaImpostoDAO")
|
|
public class EmpresaImpostoHibernateDAO extends GenericHibernateDAO<EmpresaImposto, Integer>
|
|
implements EmpresaImpostoDAO {
|
|
|
|
@Autowired
|
|
public EmpresaImpostoHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
|
setSessionFactory(factory);
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
@Override
|
|
public List<EmpresaImposto> 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<EmpresaImposto> buscarByEmpresa(Empresa empresa) {
|
|
return buscarEmpresaImposto(empresa.getEmpresaId());
|
|
}
|
|
|
|
}
|