/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package ec.gob.mcds.seguridades.dao; import ec.gob.mcds.seguridades.generico.Generico; import ec.gob.mcds.seguridades.model.Rol; import ec.gob.mcds.seguridades.model.RolMenu; import java.util.List; import javax.ejb.LocalBean; import javax.ejb.Stateless; import javax.persistence.Query; /** * * @author christian */ @LocalBean @Stateless public class RolMenuDao extends Generico<RolMenu> { public RolMenuDao() { super(RolMenu.class); } /** * método que devuelve todos los roles menus por rol de seguridades. * * @param rol * @throws Exception * @return List */ public List<RolMenu> listarPorRol(Rol rol)throws Exception{ String jpaQl = "SELECT r FROM RolMenu r WHERE r.rol = :rol"; Query query = getEntityManager().createQuery(jpaQl); query.setParameter("rol", rol); return query.getResultList(); } /** * método que eliminar fisicamente por idRol. * * @param idRol * @throws Excepcion */ public void eliminarPorRol(Long idRol) throws Exception { String sql = "DELETE FROM sch_seguridades.rol_menu WHERE rol_id = " + idRol; Query query = getEntityManager().createNativeQuery(sql); query.executeUpdate(); } }