diseasehistorydao.java

来自「是一个J2EE的项目,在eclipse下编译通过,应用struts,hibern」· Java 代码 · 共 87 行

JAVA
87
字号
package com.bjjd.DAO;
import java.util.ArrayList;
import com.bjjd.datamodel.Diseasehistory;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
/*
 * 疾病史数据持久层DAO
 * 
 */
public class DiseasehistoryDAO {
	//查询疾病史记录方法
	public ArrayList searchdiseasehistory(String str)throws Exception{
		ArrayList diseasehistorys=null;
		Session session=null;
		try
	    {
	    	
	    	SessionFactory factory = new Configuration().configure().buildSessionFactory();
	    	 session =factory.openSession();
	    	 diseasehistorys = (ArrayList)session.createQuery("from Diseasehistory where personid ="+str).list();
	    	session.beginTransaction().commit();
	    	return diseasehistorys;
	    }
	    catch(Exception e)
	    {
	    	throw e;
	    	//return users;
	    }
	    finally
	    {
	    	session.close();
	    }
	}
	//删除疾病史记录方法
	public void deletediseasehistory(Diseasehistory mp)throws Exception{
		Session session=null;
		try{
			SessionFactory factory = new Configuration().configure().buildSessionFactory();
            session =factory.openSession();
	    	session.delete(mp);
	    	session.beginTransaction().commit();
		}
		catch(Exception e){
			throw e;
		}
		finally
	    {
	    	session.close();
	    }
	}
	//新建疾病史记录方法
	public void creatediseasehistory(Diseasehistory mp)throws Exception{
		Session session=null;
		try{
			SessionFactory factory = new Configuration().configure().buildSessionFactory();
            session =factory.openSession();
	    	//session.save(mp);
	    	//session.beginTransaction().commit();
		}
		catch(Exception e){
			throw e;
		}
		finally
	    {
	    	session.close();
	    }
	}
	//修改疾病史记录方法
	public void updatediseasehistory(Diseasehistory mp)throws Exception{
		Session session=null;
		try{
			SessionFactory factory = new Configuration().configure().buildSessionFactory();
            session =factory.openSession();
	    	//session.update(mp);
	    	//session.beginTransaction().commit();
		}
		catch(Exception e){
			throw e;
		}
		finally
	    {
	    	session.close();
	    }
	}
}

⌨️ 快捷键说明

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