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

📄 u05bo.java

📁 持久层hibernate技术使用的一个例子
💻 JAVA
字号:
package cn.hope.mana.bo;

import java.util.List;

import org.apache.log4j.Logger;

import net.sf.hibernate.HibernateException;
import cn.hope.mana.pojo.TQuestion;
import cn.hope.mana.pojo.U07CommonListVO;
import cn.hope.mana.pojo.dao.CSubjectDAO;
import cn.hope.mana.pojo.dao.TInfoDAO;
import cn.hope.mana.pojo.dao.TQtypeDAO;
import cn.hope.mana.pojo.dao.TQuestionDAO;
import cn.hope.mana.pojo.dao.TTestDAO;
import cn.hope.mana.util.U07Page;

public class U05BO {
	
	Logger log = Logger.getLogger(U05BO.class.getName());
	
	CSubjectDAO cSubjectDAO = new CSubjectDAO();
	TQtypeDAO tQtypeDAO = new TQtypeDAO();
	TInfoDAO tInfoDAO = new TInfoDAO();
	TQuestionDAO tQuestionDAO = new TQuestionDAO();
	TTestDAO tTestDAO = new TTestDAO();
	
	/**
	 * 登陆
	 */	
	List list = null;
	
	public List searchInfo(String userName,String password) throws HibernateException{
		list = tInfoDAO.U05login(userName,password);
		return list;
	}
	
	/**
	 * 查询学科,题型,考题数量
	 */
	
	List SSbname = null;
	List tqtName = null;
	List tQuestion = null;
	
	public List searchSSbname() throws HibernateException {
		SSbname = cSubjectDAO.U05searchCSubject();
		return SSbname;
	}
	
	public List searchtqtName() throws HibernateException{
		tqtName = tQtypeDAO.U05searchtTQtype();
		return tqtName;
	}

	public List searchTQuestion()throws HibernateException{
		tQuestion = tQuestionDAO.U05searchTQuestion();
		return tQuestion;
	}
	
	/**
	 * 分页
	 */
	
	public U07CommonListVO serach(Integer sSid,Integer tqtId, int start, boolean isEq)
	throws Exception {
		U07CommonListVO cl_vo = new U07CommonListVO();
		int range = 5;// 每页显示记录数
		int count = 0;// 总记录数
		List list = null;// 查询得到的结果集
		U07Page page = new U07Page();// 分页
		String fenyeStr = "";
		try {
			list = tQuestionDAO.U05search(sSid, tqtId,start, range, isEq);
			count = tQuestionDAO.getCount();
			cl_vo.setRs(list);
			cl_vo.setCount(count);
			cl_vo.setStart(start);
			cl_vo.setRange(range);
		
			fenyeStr = page.fenye(cl_vo);
			cl_vo.setFenye(fenyeStr);
			cl_vo.setCurrentPage(page.getCurrentPage());
			cl_vo.setTotalPage(page.getTotalPage());
			cl_vo.setStartSub(page.getStartSub());
			cl_vo.setOverSub(page.getOverSub());
		} catch (Exception e) {
			log.error(e);
			e.printStackTrace();
			throw new Exception(e);
		}
		return cl_vo;
	}
	
	
	public U07CommonListVO serach(Integer SSid, int start, boolean isEq)
	throws Exception {
		U07CommonListVO cl_vo = new U07CommonListVO();
		int range = 5;// 每页显示记录数
		int count = 0;// 总记录数
		List list = null;// 查询得到的结果集
		U07Page page = new U07Page();// 分页
		String fenyeStr = "";
		try {
			list = tQuestionDAO.U05search(SSid,start, range, isEq);
			count = tQuestionDAO.getCount();
			cl_vo.setRs(list);
			cl_vo.setCount(count);
			cl_vo.setStart(start);
			cl_vo.setRange(range);
		
			fenyeStr = page.fenye(cl_vo);
			cl_vo.setFenye(fenyeStr);
			cl_vo.setCurrentPage(page.getCurrentPage());
			cl_vo.setTotalPage(page.getTotalPage());
			cl_vo.setStartSub(page.getStartSub());
			cl_vo.setOverSub(page.getOverSub());
		} catch (Exception e) {
			log.error(e);
			e.printStackTrace();
			throw new Exception(e);
		}
		return cl_vo;
	}

	/**
	 * 删除
	 */

	public void delete(String[] a) throws HibernateException {
		tQuestionDAO.U05del(a);	
	}
	
	public void delete(Integer questionID) throws HibernateException {
		tQuestionDAO.U05del(questionID);	
	}
	
	/**
	 * 查询试题是否存在Ttest表中
	 */
	public int searchTest(String[] a) throws HibernateException {
		int id =0;
		id = tTestDAO.searchTest(a);	
		return id;
	}
	
	/**
	 * 查询学科试题
	 */
	
	List CSubjectQuestions = null;
	
	public List searchCSubjectQuestions(Integer id) throws HibernateException{
		CSubjectQuestions = tQuestionDAO.U05searchCSubjectQuestions(id);
		return CSubjectQuestions;
	}

	/**
	 * 插入
	 */
	
	public int insert(TQuestion tQuestion) throws Exception {
		int flag = 0;
		try {
			flag = tQuestionDAO.U05insert(tQuestion).intValue();
		} catch (Exception e) {
			log.error(e);
			e.printStackTrace();
			throw new Exception(e);
		}
		return flag;
	}
	
	/**
	 * 修改
	 */
	
	public void amend(Integer questionID,String questions,String answer) throws Exception {
		tQuestionDAO.U05amend(questionID,questions,answer);
	}
	
	/**
	 * 根据题号查询试题
	 */
	TQuestion tQuestions = new TQuestion();
	public TQuestion search(Integer questionID) throws Exception {
		tQuestions = tQuestionDAO.U05search(questionID);
		return tQuestions;
	}
	
	
	/**
	 * 查询试题是否存在Ttest表中
	 */
	public List searchTtest(Integer questionID) throws HibernateException{
		list = tTestDAO.U05searchTtest(questionID);
		return list;
	}
}

⌨️ 快捷键说明

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