AdmMono/src/com/rjconsultores/ventaboletos/dao/hibernate/RutaEmpresaHibernateDAO.java

44 lines
1.3 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.Criteria;
import org.hibernate.Query;
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.RutaEmpresaDAO;
import com.rjconsultores.ventaboletos.entidad.Empresa;
import com.rjconsultores.ventaboletos.entidad.RutaEmpresa;
/**
*
* @author Administrador
*/
@Repository("rutaEmpresaDAO")
public class RutaEmpresaHibernateDAO extends GenericHibernateDAO<RutaEmpresa, Integer>
implements RutaEmpresaDAO {
@Autowired
public RutaEmpresaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
setSessionFactory(factory);
}
public List<RutaEmpresa> obtenerPorEmpresa(Empresa empresa){
StringBuilder sb = new StringBuilder();
sb.append("select * from Ruta_Empresa where empresa_Id = :empresaId and activo = 1" );
Query qry = getSession().createSQLQuery(sb.toString());
qry.setInteger("empresaId", empresa.getEmpresaId());
return qry.list();
}
}