/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package com.rjconsultores.ventaboletos.dao.hibernate; import java.util.List; import org.hibernate.Criteria; import org.hibernate.SQLQuery; import org.hibernate.SessionFactory; import org.hibernate.criterion.Restrictions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Repository; import com.rjconsultores.ventaboletos.dao.AsientoExclusivoDAO; import com.rjconsultores.ventaboletos.entidad.AsientoExclusivo; import com.rjconsultores.ventaboletos.entidad.Corrida; /** * * @author walace */ @Repository("asientoExclusivoDAO") public class AsientoExclusivoHibernateDAO extends GenericHibernateDAO implements AsientoExclusivoDAO { @Autowired public AsientoExclusivoHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { setSessionFactory(factory); } @Override public List obtenerTodos() { Criteria c = getSession().createCriteria(getPersistentClass()); c.add(Restrictions.eq("activo", Boolean.TRUE)); return c.list(); } @Override public void borrarByCorrida(Corrida corrida) { StringBuilder sQuery = new StringBuilder("DELETE FROM ASIENTO_EXCLUSIVO WHERE corrida_Id = :corridaId AND TRUNC(feccorrida) = :feccorrida "); SQLQuery qrUpdate = getSession().createSQLQuery(sQuery.toString()); qrUpdate.setParameter("feccorrida", corrida.getId().getFeccorrida()); qrUpdate.setParameter("corridaId", corrida.getId().getCorridaId()); qrUpdate.executeUpdate(); } }