0005026: Venda Internet - Não listar serviços sem disponibilidade
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@34264 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
35f2710625
commit
2b1d670a62
|
@ -4,17 +4,23 @@
|
||||||
*/
|
*/
|
||||||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.dao.DiagramaAutobusDAO;
|
|
||||||
import com.rjconsultores.ventaboletos.entidad.DiagramaAutobus;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.hibernate.Criteria;
|
import org.hibernate.Criteria;
|
||||||
|
import org.hibernate.HibernateException;
|
||||||
|
import org.hibernate.Query;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
import org.hibernate.criterion.Order;
|
import org.hibernate.criterion.Order;
|
||||||
import org.hibernate.criterion.Restrictions;
|
import org.hibernate.criterion.Restrictions;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.dao.DiagramaAutobusDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.DiagramaAutobus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Administrador
|
* @author Administrador
|
||||||
|
@ -23,6 +29,8 @@ import org.springframework.stereotype.Repository;
|
||||||
public class DiagramaAutobusHibernateDAO extends GenericHibernateDAO<DiagramaAutobus, Short>
|
public class DiagramaAutobusHibernateDAO extends GenericHibernateDAO<DiagramaAutobus, Short>
|
||||||
implements DiagramaAutobusDAO {
|
implements DiagramaAutobusDAO {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(DiagramaAutobusHibernateDAO.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public DiagramaAutobusHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
public DiagramaAutobusHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||||
setSessionFactory(factory);
|
setSessionFactory(factory);
|
||||||
|
@ -57,4 +65,44 @@ public class DiagramaAutobusHibernateDAO extends GenericHibernateDAO<DiagramaAut
|
||||||
|
|
||||||
return c.list();
|
return c.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DiagramaAutobus suscribir(DiagramaAutobus entity) {
|
||||||
|
try {
|
||||||
|
this.getHibernateTemplate().save(entity);
|
||||||
|
updateAsientosVendibles(entity);
|
||||||
|
|
||||||
|
return entity;
|
||||||
|
} catch (final HibernateException ex) {
|
||||||
|
|
||||||
|
throw convertHibernateAccessException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DiagramaAutobus actualizacion(DiagramaAutobus entity) {
|
||||||
|
entity = getHibernateTemplate().merge(entity);
|
||||||
|
updateAsientosVendibles(entity);
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateAsientosVendibles(DiagramaAutobus entity) {
|
||||||
|
try{
|
||||||
|
StringBuilder qry = new StringBuilder();
|
||||||
|
qry.append("UPDATE diagrama_autobus ");
|
||||||
|
qry.append("SET CANTASIENTOSVENDIBLES = (SELECT Count(DD.detdiagramaautobus_id) ");
|
||||||
|
qry.append(" FROM det_diagrama_autobus DD ");
|
||||||
|
qry.append(" WHERE ");
|
||||||
|
qry.append(" DD.diagramaautobus_id = :diagramaautobus_id ");
|
||||||
|
qry.append(" AND DD.vendible = 1 ");
|
||||||
|
qry.append(" AND DD.activo = 1) ");
|
||||||
|
qry.append(" WHERE diagramaautobus_id = :diagramaautobus_id ");
|
||||||
|
|
||||||
|
Query query = getSession().createSQLQuery(qry.toString());
|
||||||
|
query.setShort("diagramaautobus_id", entity.getDiagramaautobusId());
|
||||||
|
query.executeUpdate();
|
||||||
|
} catch (final Exception ex) {
|
||||||
|
log.error(ex.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue