Package dao

Source Code of dao.OrasDao

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package dao;

import bo.Oras;
import bo.HibernateUtil;
import daoI.IOrasDao;
import java.util.Collections;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;

public class OrasDao implements IOrasDao{
Session session = null;

 

    public Oras getOrasByID(int orasID) {

        Oras oras = null;
        try {
            this.session = (Session) HibernateUtil.getSessionFactory().getCurrentSession();
            org.hibernate.Transaction tx = session.beginTransaction();
            oras = (Oras) session.get(Oras.class, orasID);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return oras;
    }

    public List getAll() {
        List<Oras> orase = null;
        try {
            this.session = (Session) HibernateUtil.getSessionFactory().getCurrentSession();
            org.hibernate.Transaction tx = session.beginTransaction();
            Query q = session.createQuery("from Oras");
            orase = (List<Oras>) q.list();
            Collections.reverse(orase);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return orase;
    }

    public List getOraseByJudetId(int judetID) {
        List<Oras> orase = null;
        try {
            this.session = (Session) HibernateUtil.getSessionFactory().getCurrentSession();
            org.hibernate.Transaction tx = session.beginTransaction();
            Query q = session.createQuery("from Oras as oras where oras.judet.idJudet = '" + judetID + "'");
            orase = (List<Oras>) q.list();
            Collections.reverse(orase);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return orase;
    }
}
TOP

Related Classes of dao.OrasDao

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.