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

📄 u04studentbo.java

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



//import java.sql.Date;


import java.util.List;

import org.apache.log4j.Logger;

//import cn.hope.mana.pojo.SCity;
//import cn.hope.mana.pojo.SClass;


import cn.hope.mana.pojo.SClass;
import cn.hope.mana.pojo.Student;
import cn.hope.mana.pojo.U04CommonListVO;
import cn.hope.mana.pojo.dao.StudentDAO;
import cn.hope.mana.util.U04Page;

public class U04StudentBO {
    Logger log = Logger.getLogger(U04StudentBO.class.getName());
    
    private StudentDAO studentDAO = new StudentDAO();
  //添加 
    public String insert(Student student)throws Exception{   //添加记录方法
    	String sid = null;    //学生表主键
    	try{
    		sid = studentDAO.u04insert(student);//调用dao的insert方法添加一条记录,返回学生主键
    	}catch(Exception e){
    		log.error(e);
    		e.printStackTrace();
    		throw new Exception(e);
    	}
    	return sid;
    }
    public void modify(Student student){//学生信息修改方法
    	try{
    		studentDAO.u04modify(student);//调用dao的修改方法
    	}catch(Exception e){
    		log.error(e);
    		e.printStackTrace();
    	}
    }
    //查询所有学生
    public U04CommonListVO serachAll(Student student, int start)throws Exception{//查询所有学生记录
    	U04CommonListVO cl_vo  = new U04CommonListVO(); 
    	int range = 10;      //一页显示记录数
    	int count = 0;      //记录总数
    	List list = null;    //查询信息的集合
    	U04Page page = new U04Page();
    	String fenyeStr="";       
    	try{
    		list = studentDAO.u04searchAll(student,start,range);//调用dao的查询所有学生信息方法
    		count = studentDAO.getCount();//获得记录总数
    		cl_vo.setRs(list);    //集合set到U04COmmonLIstVO
    		cl_vo.setCount(count);//把总记录数set到U04COmmonLIstVO
    		cl_vo.setStart(start);//把起始记录数set到U04COmmonLIstVO
    		cl_vo.setRange(range);//一页显示记录数set到U04COmmonLIstVO
    		
    		fenyeStr = page.fenye(cl_vo);              
    		cl_vo.setFenye(fenyeStr);                    //把分页jsp语句set到U04COmmonLIstVO
    		cl_vo.setCurrentPage(page.getCurrentPage());//把当前页数set到U04COmmonLIstVO
    		cl_vo.setTotalPage(page.getTotalPage());//把总页数set到U04COmmonLIstVO
    		cl_vo.setStartSub(page.getStartSub());//把首页set到U04COmmonLIstVO
    		cl_vo.setOverSub(page.getOverSub());//把尾页set到U04COmmonLIstVO
    	}catch(Exception e){
    		log.error(e);
    		e.printStackTrace();
    		throw new Exception(e);
    		
    	}
    	return cl_vo;
    }

   
    //按条件查返回对象不同
    public Student searchByKey(String id,boolean isEq)throws Exception{
    	Student stud = new Student();
    	try{
    		stud = studentDAO.u04searchByKey(id,isEq);
    	}catch(Exception e){
    		log.error(e);
    		e.printStackTrace();
    	}
    	return stud;
    }
  //查询所有班级  
    public List U04ClassSearchAll(SClass sClass)throws Exception{
    	List list = null;
    	try{
    		list = studentDAO.u04ClassSearchAll(sClass);
    	}catch(Exception e){
    		log.error(e);
    		e.printStackTrace();
    	}
    	return list;
    }
    //通过班级id查询学生
    public U04CommonListVO classSerachAll(int classid, int start)throws Exception{//查询所有学生记录
    	U04CommonListVO cl_vo  = new U04CommonListVO(); 
    	int range = 10;      //一页显示记录数
    	int count = 0;      //记录总数
    	List list = null;    //查询信息的集合
    	U04Page page = new U04Page();
    	String fenyeStr="";       
    	try{
    		list = studentDAO.u04seaClass(classid,start,range);//调用dao的查询所有学生信息方法
    		count = studentDAO.getCount();//获得记录总数
    		cl_vo.setRs(list);    //集合set到U04COmmonLIstVO
    		cl_vo.setCount(count);//把总记录数set到U04COmmonLIstVO
    		cl_vo.setStart(start);//把起始记录数set到U04COmmonLIstVO
    		cl_vo.setRange(range);//一页显示记录数set到U04COmmonLIstVO
    		
    		fenyeStr = page.fenye(cl_vo);              
    		cl_vo.setFenye(fenyeStr);                    //把分页jsp语句set到U04COmmonLIstVO
    		cl_vo.setCurrentPage(page.getCurrentPage());//把当前页数set到U04COmmonLIstVO
    		cl_vo.setTotalPage(page.getTotalPage());//把总页数set到U04COmmonLIstVO
    		cl_vo.setStartSub(page.getStartSub());//把首页set到U04COmmonLIstVO
    		cl_vo.setOverSub(page.getOverSub());//把尾页set到U04COmmonLIstVO
    	}catch(Exception e){
    		log.error(e);
    		e.printStackTrace();
    		throw new Exception(e);
    		
    	}
    	return cl_vo;
    }
    //通过用户名查询,是否完全匹配
    public U04CommonListVO serachName(String nameText, int start,boolean isEq)throws Exception{//查询所有学生记录
    	U04CommonListVO cl_vo  = new U04CommonListVO(); 
    	int range = 5;      //一页显示记录数
    	int count = 0;      //记录总数
    	List list = null;    //查询信息的集合
    	U04Page page = new U04Page();
    	String fenyeStr="";       
    	try{
    		list = studentDAO.u04seaName(nameText,start,range,isEq);//调用dao的查询所有学生信息方法
    		count = studentDAO.getCount();//获得记录总数
    		cl_vo.setRs(list);    //集合set到U04COmmonLIstVO
    		cl_vo.setCount(count);//把总记录数set到U04COmmonLIstVO
    		cl_vo.setStart(start);//把起始记录数set到U04COmmonLIstVO
    		cl_vo.setRange(range);//一页显示记录数set到U04COmmonLIstVO
    		
    		fenyeStr = page.fenye(cl_vo);              
    		cl_vo.setFenye(fenyeStr);                    //把分页jsp语句set到U04COmmonLIstVO
    		cl_vo.setCurrentPage(page.getCurrentPage());//把当前页数set到U04COmmonLIstVO
    		cl_vo.setTotalPage(page.getTotalPage());//把总页数set到U04COmmonLIstVO
    		cl_vo.setStartSub(page.getStartSub());//把首页set到U04COmmonLIstVO
    		cl_vo.setOverSub(page.getOverSub());//把尾页set到U04COmmonLIstVO
    	}catch(Exception e){
    		log.error(e);
    		e.printStackTrace();
    		throw new Exception(e);
    	}
    	return cl_vo;
    }
    //判断是否添写用户名
    public boolean uName(String username){
    	if((username!=null)&&(!username.equals(""))){
    		return true;
    }
    	return false;
    }
    
}

⌨️ 快捷键说明

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