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

📄 u04a100bo.java

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

import java.util.List;

import org.apache.log4j.Logger;

import net.sf.hibernate.HibernateException;

import cn.hope.front.pojo.TQuestion;
import cn.hope.front.pojo.TTest;
import cn.hope.front.pojo.TTestInfo;


import cn.hope.front.pojo.U07CommonListVO;
import cn.hope.front.pojo.dao.TQtypeDAO;
import cn.hope.front.pojo.dao.TQuestionDAO;
import cn.hope.front.pojo.dao.TTestDAO;
import cn.hope.front.pojo.dao.TTestInfoDAO;

import cn.hope.front.util.U07Page;
import cn.hope.front.util.Utility;

public class U04A100BO {
	
	Logger log = Logger.getLogger(U04C1BO.class.getName());
		public List searchtqtName() throws HibernateException{
			
			TQtypeDAO tQtypeDAO = new TQtypeDAO();
			List tqtName = null;
			tqtName = tQtypeDAO.searchtTQtype();
			return tqtName;
		}
		
		public U07CommonListVO serachQues(TQuestion tQuestion,int start, boolean isEq)throws Exception {
			U07CommonListVO cl_vo = new U07CommonListVO();
			TQuestionDAO tQuestionDAO = new TQuestionDAO();
			int range = 10;// 每页显示记录数
			int count = 0;// 总记录数
			List list = null;// 查询得到的结果集
			U07Page page = new U07Page();// 分页
			String fenyeStr = "";
			TQuestion tQuestions = new TQuestion();
			try {
				
				list = tQuestionDAO.searchQuesinfo(tQuestion, start, range, isEq);//得到结果集
				for(int i=0;i<list.size();i++){
					tQuestions = (TQuestion) list.get(i);
					tQuestions.setTqName(Utility.formatEnterStr(tQuestions.getTqName()));
				}
				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 Integer saves(TTest tTest)  throws Exception{
			Integer id = null;
			TTestDAO tTestDAO = new TTestDAO();
			try{
				id = tTestDAO.insert(tTest);
			}
			catch(Exception e){
				log.error(e);
				e.printStackTrace();
				throw new Exception(e);
			}
			return id;
		}
		
		
		public List looks(String info,String tq)  throws Exception{
			List list = null;
			TTestDAO tTestDAO = new TTestDAO();
			try{
				list = tTestDAO.searchByKey(info,tq);
			}
			catch(Exception e){
				log.error(e);
				e.printStackTrace();
				throw new Exception(e);
			}
			return list;
		}
		
		
		
		public int total(String id)  throws Exception{
			TTestDAO tTestDAO = new TTestDAO();
			List list = null;
			TTest tTest = new TTest();
			int total=0;
			list = tTestDAO.U01D2120Tquest(id);
			if(list.size()>0){
				for (int i=0;i<list.size();i++) {
					tTest = (TTest) list.get(i);
					total+=tTest.getTQuestionspoint();
					System.out.println(total+"::::::::::::::::::::::::::::::::::::::::::::::::::::::::::");
				}
			}	
			return total;
		}
		
		public int getIds(String id)  throws Exception{
			TTestInfo testInfo = new TTestInfo();
			TTestInfoDAO tTestInfoDAO = new TTestInfoDAO();
			testInfo = tTestInfoDAO.testInfo(id);
			int ids = testInfo.getTTestpoint();
			return ids;
			
		}
}

⌨️ 快捷键说明

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