/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.rjconsultores.ventaboletos.dao.hibernate;

import com.rjconsultores.ventaboletos.dao.TipoDomicilioDAO;
import com.rjconsultores.ventaboletos.entidad.TipoDomicilio;
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;

/**
 *
 * @author Administrador
 */
@Repository("tipoDomicilioDAO")
public class TipoDomicilioHibernateDAO extends GenericHibernateDAO<TipoDomicilio, Integer>
        implements TipoDomicilioDAO {

    @Autowired
    public TipoDomicilioHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
        setSessionFactory(factory);
    }

    @Override
    public List<TipoDomicilio> obtenerTodos() {
        Criteria c = getSession().createCriteria(getPersistentClass());
        c.add(Restrictions.eq(ACTIVO, Boolean.TRUE));

        return c.list();
    }

    public List<TipoDomicilio> buscar(String desctipo, String cvetipodomicilio) {
        Criteria c = getSession().createCriteria(getPersistentClass());
        c.add(Restrictions.eq(ACTIVO, Boolean.TRUE));

        c.add(Restrictions.eq("desctipo", desctipo));
        c.add(Restrictions.eq("cvetipodomicilio", cvetipodomicilio));

        return c.list();
    }

    public List<TipoDomicilio> buscarClave(String cvetipodomicilio) {
        Criteria c = getSession().createCriteria(getPersistentClass());
        c.add(Restrictions.eq(ACTIVO, Boolean.TRUE));

        c.add(Restrictions.eq("cvetipodomicilio", cvetipodomicilio));

        return c.list();
    }
}
