Package hsv.DAO

Source Code of hsv.DAO.RepasseDAO

package hsv.DAO;

import hsv.beans.RepassePA;
import org.hibernate.Query;
import org.hibernate.Session;

public class RepasseDAO {

    public void salvarDados(RepassePA repasse) {
        Session session = HibernateUtil.getSessionFactory().openSession();
        session.beginTransaction();
        session.save(repasse);
        session.getTransaction().commit();
        session.close();
    }

    public void editar(RepassePA repasse) {
        Session session = HibernateUtil.getSessionFactory().openSession();
        session.beginTransaction();
        session.update(repasse);
        session.getTransaction().commit();
        session.close();
    }

    public RepassePA consultar(RepassePA repasse) {
        Session session = HibernateUtil.getSessionFactory().openSession();
        session.beginTransaction();
        Query select = session.createQuery("FROM RepassePA WHERE dataVigencia = :data AND codPrestador = :prestador");
        select.setDate("data", repasse.getDataVigencia());
        select.setInteger("prestador", repasse.getCodPrestador());
        RepassePA resultado = (RepassePA) select.uniqueResult();
        session.getTransaction().commit();
        session.close();
        return resultado;
    }
}
TOP

Related Classes of hsv.DAO.RepasseDAO

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.