package zemplen.report;

import hibergui.hibernate.SessionManager;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

import zemplen.Main;

public class ReportData {

//	private SessionFactory sf;
//	private Session session;

	public ReportData() {
//		if (SessionManager.instance() == null)
//			SessionManager.initialize();
//		open(Main.cfg);
	}
	
	public ReportData(String config) {
//		if (SessionManager.instance() == null)
//			SessionManager.initialize(config);
//		open(new Configuration().configure(config));
	}
	
//	private void open(Configuration conf) {
//		sf = conf.buildSessionFactory();
//		session = sf.openSession();
//	}
	
	public void close() {
//		session.close();
//		sf.close();
//		SessionManager.instance().close();
	}
	
	@SuppressWarnings("unchecked")
	public List list(String hql) {
		Transaction trans = SessionManager.instance().getSession().beginTransaction();
		List result = SessionManager.instance().getSession().createQuery(hql).list();
		trans.commit();
		return result;
	}
/*
	public static void main(String[] args) {
		ReportData rd = new ReportData();
		System.out.println(rd.list("from Nevezes"));
		rd.close();
	}
*/
}
