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

📄 questionservice.java

📁 在线考试功能
💻 JAVA
字号:
package com.onlinestudy.service;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.onlinestudy.domain.QuestionType;
import com.onlinestudy.domain.Questions;

public class QuestionService extends HibernateDaoSupport {
	
	ListForPage listForpage;
	

	//显示试题类型
	public List showQuestionType(){
		List list = this.getHibernateTemplate().find("from QuestionType");		
		return list;
	}
	
	//增加试题类型
	public void addQuestionType(QuestionType qType){
		this.getHibernateTemplate().save(qType);		
	}
	//按ID查询
	public QuestionType SelectQTypeById(int id){
		QuestionType qt = (QuestionType)this.getHibernateTemplate().find("from QuestionType where id="+id).get(0);		
		return qt;
	}
	
	//修改试题类型
	public void updateQuestionType(QuestionType qType){
		this.getHibernateTemplate().update(qType);
	}
	//删除试题类型
	public void deleteQuestionType(int id){	
		this.getHibernateTemplate().delete((QuestionType)this.getHibernateTemplate().find("from QuestionType where id="+id).get(0));
	}
	
	//分页查询试题
	public List selectQuestionForpage(String hql, int offset, int length){
	
		List list = listForpage.getListForPage(hql, offset, length);
		return list;
	}
	
	//查询试题数
	public int CountQuestion(){
		int count = this.getHibernateTemplate().find("select id from Questions").size();
		return count;
	}
	
	//增加试题
	public void addQuestion(Questions qt){
		this.getHibernateTemplate().save(qt);
	}
	
	//按ID查询试题
	public Questions selectQuestionById(int id){
		Questions qt = (Questions)this.getHibernateTemplate().find("from Questions where id="+id).get(0);
		return qt;
	}
	
	//修改试题
	public void updateQuestion(Questions qt){
		this.getHibernateTemplate().update(qt);
	}
	
	//删除试题
	public void deleteQuestion(String[] ids){
		
		for(int i = 0; i < ids.length; i++){
			int id = Integer.parseInt(ids[i]);
			Questions q = this.selectQuestionById(id);
			this.getHibernateTemplate().delete(q);
		}
		
	}

	public void setListForpage(ListForPage listForpage) {
		this.listForpage = listForpage;
	}

}

⌨️ 快捷键说明

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