From 07e520686925865c78e20860a3d7a452d562734b Mon Sep 17 00:00:00 2001 From: valdevir Date: Wed, 11 Jan 2017 17:25:17 +0000 Subject: [PATCH] fixes bug #8524 git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@64826 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../dao/hibernate/CorridaHibernateDAO.java | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/CorridaHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/CorridaHibernateDAO.java index d685b5a97..a771b51d5 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/CorridaHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/CorridaHibernateDAO.java @@ -776,20 +776,28 @@ public class CorridaHibernateDAO extends GenericHibernateDAO 0 "); - sql.append(corridaId == null ? "" : " and c.corrida_id = :corridaId "); + if(corridaId!=null){ + sql.append(" and c.corrida_id = :corridaId "); + } sql.append(feccorrida == null ? "" : " and c.feccorrida = :feccorrida "); - sql.append(origem == null ? "" : " and c.origen_id = :origen_id "); - sql.append(destino == null ? "" : " and c.destino_id = :destino_id "); + if(origem!=null){ + sql.append(origem == null ? "" : " and c.origen_id = :origen_id "); + } + if(destino!=null){ + sql.append(destino == null ? "" : " and c.destino_id = :destino_id "); + } Query query = getSession().createSQLQuery(sql.toString()); if (corridaId != null) { query.setParameter("corridaId", corridaId); - } else { - query.setParameter("corridaId", '%'); - } + } query.setParameter("feccorrida", feccorrida); - query.setParameter("origen_id", origem.getParadaId()); - query.setParameter("destino_id", destino.getParadaId()); + if(origem!=null){ + query.setParameter("origen_id", origem.getParadaId()); + } + if(destino!=null){ + query.setParameter("destino_id", destino.getParadaId()); + } List lsObject = query.list();