package com.zhuohua.student.dao.impl;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Component;

import com.zhuohua.student.dao.ExaminationDao;
import com.zhuohua.student.model.Examination;
@Component("studentExaminationDao")
public class ExaminationDaoImpl implements ExaminationDao{
	private SessionFactory sessionFactory;
	@Resource(name="sessionFactory")
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}
	private Session getSession(){
		return this.sessionFactory.getCurrentSession();
	}
	@Override
	public List<Examination> findByCourseNo(String courseNo) {
		String hql = "from studentExamination e where e.course.courseNo = :courseNo";
		return this.getSession().createQuery(hql).setString("courseNo", courseNo).list();
	}
	
}
