From 17996c26f45458393ca356b38d0d9aec29ebaa7b Mon Sep 17 00:00:00 2001 From: julio Date: Thu, 29 Dec 2016 17:05:59 +0000 Subject: [PATCH] bug #8121 git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@64307 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../dao/hibernate/AidfHibernateDAO.java | 21 ++++++--- .../ventaboletos/entidad/Aidf.java | 4 +- .../ventaboletos/entidad/AidfEspecie.java | 46 ++++++++++--------- 3 files changed, 39 insertions(+), 32 deletions(-) diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/AidfHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/AidfHibernateDAO.java index f785667cd..4a44c711d 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/AidfHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/AidfHibernateDAO.java @@ -8,6 +8,7 @@ import java.util.List; import org.apache.log4j.Logger; import org.hibernate.Criteria; +import org.hibernate.Query; import org.hibernate.SessionFactory; import org.hibernate.criterion.Restrictions; import org.springframework.beans.factory.annotation.Autowired; @@ -133,14 +134,20 @@ public class AidfHibernateDAO extends GenericHibernateDAO implements @Override public List buscaAidfRMD(Integer empresaId, Integer estadoId) { - Criteria c = getSession().createCriteria(getPersistentClass()); - c.add(Restrictions.eq("activo", Boolean.TRUE)); - c.add(Restrictions.eq("estado.estadoId", estadoId)); - c.add(Restrictions.eq("empresa.empresaId", empresaId)); - -// c.add(Restrictions.eq("aidfEspecie.decespecie", "RMD")); + StringBuilder sb = new StringBuilder(); + sb.append(" from Aidf "); + sb.append(" where activo = :activo "); + sb.append(" and estado.estadoId = :estadoId "); + sb.append(" and empresa.empresaId = :empresaId "); + sb.append(" and aidfEspecie.decespecie = 'RMD' "); - return (List) c.list(); + Query query = getSession().createQuery(sb.toString()); + + query.setBoolean("activo", Boolean.TRUE); + query.setInteger("estadoId", estadoId); + query.setInteger("empresaId", empresaId); + + return (List) query.list(); } } diff --git a/src/com/rjconsultores/ventaboletos/entidad/Aidf.java b/src/com/rjconsultores/ventaboletos/entidad/Aidf.java index 2a57e8ef9..1d7d5b3aa 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/Aidf.java +++ b/src/com/rjconsultores/ventaboletos/entidad/Aidf.java @@ -24,10 +24,8 @@ import org.hibernate.annotations.GenericGenerator; @Table(name = "AIDF") public class Aidf implements java.io.Serializable { - /** - * - */ private static final long serialVersionUID = 1L; + private Long aidfId; private AidfTipo aidfTipo; private AidfEspecie aidfEspecie; diff --git a/src/com/rjconsultores/ventaboletos/entidad/AidfEspecie.java b/src/com/rjconsultores/ventaboletos/entidad/AidfEspecie.java index 69323235a..6bbdf878e 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/AidfEspecie.java +++ b/src/com/rjconsultores/ventaboletos/entidad/AidfEspecie.java @@ -18,6 +18,8 @@ import javax.persistence.TemporalType; @Table(name = "AIDF_ESPECIE") public class AidfEspecie implements java.io.Serializable { + private static final long serialVersionUID = 1L; + private Integer aidfespId; private String decespecie; private Boolean activo; @@ -30,32 +32,32 @@ public class AidfEspecie implements java.io.Serializable { public AidfEspecie(Integer aidfespId) { this.aidfespId = aidfespId; } - + @Override - public String toString() { + public String toString() { return decespecie; } - - @Override - public int hashCode() { - int hash = 0; - hash += (aidfespId != null ? aidfespId.hashCode() : 0); - return hash; - } - @Override - public boolean equals(Object object) { - // TODO: Warning - this method won't work in the case the id fields are not set - if (!(object instanceof AidfEspecie)) - return false; - - AidfEspecie other = (AidfEspecie) object; - if ((this.aidfespId == null && other.aidfespId != null) || (this.aidfespId != null && !this.aidfespId.equals(other.aidfespId))) { - return false; - } - return true; - } - + @Override + public int hashCode() { + int hash = 0; + hash += (aidfespId != null ? aidfespId.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object object) { + // TODO: Warning - this method won't work in the case the id fields are not set + if (!(object instanceof AidfEspecie)) + return false; + + AidfEspecie other = (AidfEspecie) object; + if ((this.aidfespId == null && other.aidfespId != null) || (this.aidfespId != null && !this.aidfespId.equals(other.aidfespId))) { + return false; + } + return true; + } + public AidfEspecie(Integer aidfespId, String decespecie, Boolean activo, Date fecmodif, Integer usuarioId) { this.aidfespId = aidfespId; this.decespecie = decespecie;