53 lines
1.7 KiB
Java
53 lines
1.7 KiB
Java
package com.rjconsultores.ventaboletos.dao.hibernate;
|
|
|
|
import java.util.List;
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
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.PrecoApanheDAO;
|
|
import com.rjconsultores.ventaboletos.entidad.PrecoApanhe;
|
|
|
|
@Repository("precoApanheDAO")
|
|
public class PrecoApanheHibernateDAO extends GenericHibernateDAO<PrecoApanhe, Integer> implements PrecoApanheDAO {
|
|
|
|
@Autowired
|
|
public PrecoApanheHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
|
setSessionFactory(factory);
|
|
}
|
|
|
|
@Override
|
|
@SuppressWarnings("unchecked")
|
|
public List<PrecoApanhe> obtenerTodos() {
|
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
|
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
|
|
|
return c.list();
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
public List<PrecoApanhe> buscar(String deschotel, String desccolonia, String nombciudad) {
|
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
|
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
|
|
|
if(StringUtils.isNotBlank(deschotel)) {
|
|
c.add(Restrictions.eq("hotel.deschotel", deschotel));
|
|
}
|
|
|
|
if(StringUtils.isNotBlank(desccolonia)) {
|
|
c.add(Restrictions.eq("colonia.desccolonia", desccolonia));
|
|
}
|
|
|
|
if(StringUtils.isNotBlank(nombciudad)) {
|
|
c.add(Restrictions.eq("ciudad.nombciudad", nombciudad));
|
|
}
|
|
|
|
return c.list();
|
|
}
|
|
}
|