package ub.scp2.daoImpl;

import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.SessionFactory;
import org.hibernate.classic.Session;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;

import ub.scp2.dao.TestDao;
import ub.scp2.entities.Task;
import ub.scp2.entities.Test;

/**
 * TestDaoImpl.java -this class implements the TestDao. This is the Data Acces Object of the Test entity
 * 
 *
 */
public class TestDaoImpl implements TestDao, java.io.Serializable{
	SessionFactory sessionFactory;
	
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	/**
	 * Delete test in database
	 */
    public void deleteTest(Test test) {
		 Session session = sessionFactory.getCurrentSession();
		 
		 try{
				 session.delete(test);
				 session.flush(); 
		 }catch(Exception e){
			 e.printStackTrace();
		 }
		
	}

    /**
     * Save test in database
     */
	public void saveTest(Test test) {
		 Session session = sessionFactory.getCurrentSession();
		 
		 try{
				 session.save(test);
				 session.flush(); 
		 }catch(Exception e){
			 e.printStackTrace();
		 }
		
	}
}
