package hsv.DAO;
import org.hibernate.Session;
import hsv.beans.RepasseBanco;
import org.hibernate.Query;
public class RepasseBancoDAO {
public void salvarDados(RepasseBanco repasse) {
Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
session.save(repasse);
session.getTransaction().commit();
}
public void editar(RepasseBanco repasse) {
Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
session.update(repasse);
session.getTransaction().commit();
session.close();
//return resultado;
}
public RepasseBanco consultar(RepasseBanco repasse){
Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
Query select = session.createQuery("FROM RepasseBanco WHERE dataVigencia = :data");
select.setDate("data", repasse.getDataVigencia());
RepasseBanco resultado = (RepasseBanco) select.uniqueResult();
session.getTransaction().commit();
session.close();
return resultado;
}
}