85 lines
2.6 KiB
Java
85 lines
2.6 KiB
Java
/*
|
|
* 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.CiudadDAO;
|
|
import com.rjconsultores.ventaboletos.entidad.Ciudad;
|
|
import com.rjconsultores.ventaboletos.entidad.Estado;
|
|
import com.rjconsultores.ventaboletos.entidad.Plaza;
|
|
import java.util.List;
|
|
import org.hibernate.Criteria;
|
|
import org.hibernate.SessionFactory;
|
|
import org.hibernate.criterion.MatchMode;
|
|
import org.hibernate.criterion.Order;
|
|
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 MCosso
|
|
*/
|
|
@Repository("ciudadDAO")
|
|
public class CiudadHibernateDAO extends GenericHibernateDAO<Ciudad, Integer>
|
|
implements CiudadDAO {
|
|
|
|
@Autowired
|
|
public CiudadHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
|
setSessionFactory(factory);
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
@Override
|
|
public List<Ciudad> obtenerTodos() {
|
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
|
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
|
c.addOrder(Order.asc("nombciudad"));
|
|
|
|
return c.list();
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
public List<Ciudad> buscar(String nombciudad, Estado estado, Plaza plaza) {
|
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
|
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
|
c.add(Restrictions.eq("nombciudad", nombciudad));
|
|
c.add(Restrictions.eq("estado", estado));
|
|
|
|
return c.list();
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
public List<Ciudad> buscaLike(String strCiudad) {
|
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
|
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
|
c.add(Restrictions.like("nombciudad", strCiudad, MatchMode.START));
|
|
c.addOrder(Order.asc("nombciudad"));
|
|
|
|
return c.list();
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
@Override
|
|
public List<Ciudad> buscarPorEstado(Estado estado) {
|
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
|
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
|
c.add(Restrictions.eq("estado", estado));
|
|
c.addOrder(Order.asc("nombciudad"));
|
|
|
|
return c.list();
|
|
}
|
|
|
|
@Override
|
|
public List<Ciudad> buscaCodMun(Integer codMun, Estado estado) {
|
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
|
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
|
c.add(Restrictions.eq("codmunicipio", codMun));
|
|
c.add(Restrictions.eq("estado", estado));
|
|
|
|
return c.list();
|
|
}
|
|
}
|