48 lines
1.6 KiB
Java
48 lines
1.6 KiB
Java
package com.rjconsultores.ventaboletos.dao.hibernate;
|
|
|
|
import java.util.Date;
|
|
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.EnderecoApanheDAO;
|
|
import com.rjconsultores.ventaboletos.entidad.EnderecoApanhe;
|
|
|
|
@Repository("enderecoApanheDAO")
|
|
public class EnderecoApanheHibernateDAO extends GenericHibernateDAO<EnderecoApanhe, Long> implements EnderecoApanheDAO {
|
|
|
|
@Autowired
|
|
public EnderecoApanheHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
|
setSessionFactory(factory);
|
|
}
|
|
|
|
@Override
|
|
public List<EnderecoApanhe> obtenerTodos() {
|
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
|
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
|
|
|
return c.list();
|
|
}
|
|
|
|
public List<EnderecoApanhe> buscar(Date datapacote, String numoperacion) {
|
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
|
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
|
|
|
if(datapacote != null) {
|
|
c.add(Restrictions.eq("hotel.datapacote", datapacote));
|
|
}
|
|
|
|
if(StringUtils.isNotBlank(numoperacion)) {
|
|
c.add(Restrictions.eq("hotel.numoperacion", numoperacion));
|
|
}
|
|
|
|
return c.list();
|
|
}
|
|
}
|