1 package ecar.dao; 2 3 import org.hibernate.Query; 4 5 import comum.database.Dao; 6 7 import ecar.exception.ECARException; 8 import ecar.pojo.DemandasGrpAcesso; 9 import ecar.pojo.SisAtributoSatb; 10 11 public class DemandasGrpAcessoDao extends Dao { 12 13 public DemandasGrpAcessoDao() { 14 super(); 15 } 16 17 public DemandasGrpAcesso getDemandasGrpAcesso(SisAtributoSatb satb) throws ECARException { 18 try { 19 StringBuilder query = new StringBuilder("select demandas from DemandasGrpAcesso as demandas ").append(" where demandas.codSatb = " + satb.getCodSatb()); 20 21 Query q = this.getSession().createQuery(query.toString()); 22 23 q.setMaxResults(1); 24 25 Object demanda = q.uniqueResult(); 26 27 if (demanda != null) { 28 return (DemandasGrpAcesso) demanda; 29 } 30 else { 31 return null; 32 } 33 34 } catch (Exception e) { 35 this.logger.error(e); 36 throw new ECARException(e); 37 } 38 } 39 40 }