AdmMono/src/com/rjconsultores/ventaboletos/dao/hibernate/ConductorHibernateDAO.java

55 lines
1.6 KiB
Java

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.rjconsultores.ventaboletos.dao.hibernate;
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.ConductorDAO;
import com.rjconsultores.ventaboletos.entidad.Conductor;
/**
*
* @author Administrador
*/
@Repository("conductorDAO")
public class ConductorHibernateDAO extends GenericHibernateDAO<Conductor, Integer>
implements ConductorDAO {
@Autowired
public ConductorHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
setSessionFactory(factory);
}
@Override
public List<Conductor> obtenerTodos() {
Criteria c = getSession().createCriteria(getPersistentClass());
c.add(Restrictions.eq(ACTIVO, Boolean.TRUE));
return c.list();
}
public Conductor buscar(String claveConductor, String contraSenha) {
Conductor c = new Conductor(1);
c.setNombconductor("Rafius");
return c;
}
public Conductor buscarPorEmpleado(int empleadoId){
Criteria c = getSession().createCriteria(getPersistentClass());
c.add(Restrictions.eq(ACTIVO, Boolean.TRUE));
c.add(Restrictions.eq("empleado.empleadoId", empleadoId));
return (Conductor) c.uniqueResult();
}
}