⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 studentpaperservice.java

📁 在线考试系统: 这是基于struts和Hibernate的最新技术的在线考试系统.数据库是MySql.能添加课程
💻 JAVA
字号:
package com.zjxy.service;

import java.util.*;

import org.hibernate.Session;

import com.zjxy.hibernate.HibernateSessionFactory;
import org.hibernate.Transaction;
import com.zjxy.hibernate.model.QuestionPaper;
import com.zjxy.hibernate.model.*;

public class StudentPaperService {
	
	public static StudentPaper gerneratePaper(String id,String studentid){
		
		QuestionPaper paper=new QuestionPaper();
		Session s=HibernateSessionFactory.currentSession();
		Transaction t=s.beginTransaction();
		paper=(QuestionPaper)s.get(QuestionPaper.class,Integer.valueOf(id));
		StudentPaper  sp=new StudentPaper();
		sp.setName(paper.getName());
		sp.setStudentid(studentid);
		Set questionset=paper.getExamtemp();
		Set stset=new HashSet();
		Iterator it=questionset.iterator();
		while(it.hasNext()){
			ExamForward ef=(ExamForward)it.next();
			Examing e=new Examing();
			e.setAnswer(ef.getAnswer());
			e.setKemuID(ef.getKemuID());
			e.setQuestion(ef.getQuestion());
			e.setQuestionNo(ef.getQuestionNo());
			e.setScore(ef.getScore());
			e.setTikuNO(ef.getTikuNO());
			stset.add(e);
		}
		sp.setPaperlist(stset);
		s.save(sp);
		t.commit();
		HibernateSessionFactory.closeSession();
		return sp;
	}
	
	public static List temlist(int id){
		List list=new ArrayList();
		Session s=HibernateSessionFactory.currentSession();
		String hql="from Examing where studentpaper.id="+id+" order by questionNo";
		list=s.createQuery(hql).list();
		System.out.println(list.size()+"==========");
		HibernateSessionFactory.closeSession();
		return list;
		
	}
	
	public static StudentPaper getPaperById(String id){
		StudentPaper st=new StudentPaper();
		Session s=HibernateSessionFactory.currentSession();
		st=(StudentPaper)s.get(StudentPaper.class,Integer.valueOf(id));
		HibernateSessionFactory.closeSession();;
		return st;
	}
	
	public static String replaceNull(String str){
	        String st="";
	  if(str!=null)st=str;
			return st;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -