AdmMono/src/com/rjconsultores/ventaboletos/dao/hibernate/PricingEspecificoAgenciaHib...

43 lines
1.5 KiB
Java

package com.rjconsultores.ventaboletos.dao.hibernate;
import java.util.List;
import org.hibernate.Criteria;
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.PricingEspecificoAgenciaDAO;
import com.rjconsultores.ventaboletos.entidad.PricingEspecificoAgencia;
@Repository("pricingEspecificoAgenciaDAO")
public class PricingEspecificoAgenciaHibernateDAO extends GenericHibernateDAO<PricingEspecificoAgencia, Long> implements PricingEspecificoAgenciaDAO {
@Autowired
public PricingEspecificoAgenciaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
setSessionFactory(factory);
}
@SuppressWarnings("unchecked")
@Override
public List<PricingEspecificoAgencia> obtenerTodos() {
Criteria c = getSession().createCriteria(getPersistentClass());
c.add(Restrictions.eq("activo", Boolean.TRUE));
return c.list();
}
@SuppressWarnings("unchecked")
@Override
public Boolean isDuplicado(PricingEspecificoAgencia entidad) {
Criteria c = getSession().createCriteria(getPersistentClass());
c.add(Restrictions.eq("activo", Boolean.TRUE));
c.add(Restrictions.eq("puntoVenta.puntoventaId", entidad.getPuntoVenta().getPuntoventaId()));
return c.list().isEmpty();
}
}