76 lines
2.6 KiB
Java
76 lines
2.6 KiB
Java
package com.rjconsultores.ventaboletos.dao.hibernate;
|
|
|
|
import java.util.Calendar;
|
|
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.FechamentoParamptovtaDAO;
|
|
import com.rjconsultores.ventaboletos.entidad.FechamentoParamptovta;
|
|
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
|
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
|
|
|
@Repository("fechamentoParamptovtaDAO")
|
|
public class FechamentoParamptovtaHibernateDAO extends GenericHibernateDAO<FechamentoParamptovta, Long> implements FechamentoParamptovtaDAO {
|
|
|
|
|
|
@Autowired
|
|
public FechamentoParamptovtaHibernateDAO(
|
|
@Qualifier("sessionFactory") SessionFactory factory) {
|
|
setSessionFactory(factory);
|
|
}
|
|
|
|
@Override
|
|
public List<FechamentoParamptovta> buscaParametrosPorEmpresas(List<Integer> empresasId) {
|
|
Criteria query = getSession().createCriteria(getPersistentClass());
|
|
query.createAlias("empresa", "emp");
|
|
query.add(Restrictions.in("emp.empresaId", empresasId));
|
|
query.add(Restrictions.eq("activo", Boolean.TRUE));
|
|
|
|
return (List<FechamentoParamptovta>)query.list();
|
|
}
|
|
|
|
@Override
|
|
public List<FechamentoParamptovta> obtenerTodos() {
|
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
|
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
|
|
|
return (List<FechamentoParamptovta>)c.list();
|
|
}
|
|
|
|
@Override
|
|
public List<FechamentoParamptovta> buscaParametrosPorEmpresa(Integer empresaId) {
|
|
Criteria query = getSession().createCriteria(getPersistentClass());
|
|
query.createAlias("empresa", "emp");
|
|
query.add(Restrictions.eq("emp.empresaId", empresaId));
|
|
query.add(Restrictions.eq("activo", Boolean.TRUE));
|
|
|
|
return (List<FechamentoParamptovta>)query.list();
|
|
}
|
|
|
|
@Override
|
|
public void borrar(FechamentoParamptovta entity) {
|
|
entity.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
|
entity.setFecmodif(Calendar.getInstance().getTime());
|
|
entity.setActivo(Boolean.FALSE);
|
|
actualizacion(entity);
|
|
}
|
|
|
|
@Override
|
|
public List<FechamentoParamptovta> buscaParametrosPorPuntoventa(PuntoVenta puntoventa) {
|
|
Criteria query = getSession().createCriteria(getPersistentClass());
|
|
query.add(Restrictions.eq("puntoventa", puntoventa));
|
|
query.add(Restrictions.eq("activo", Boolean.TRUE));
|
|
|
|
List<FechamentoParamptovta> params = query.list();
|
|
|
|
return params;
|
|
}
|
|
|
|
}
|