allergyhistorydao.java

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

JAVA
91
字号
package com.bjjd.DAO;
import java.util.ArrayList;
import com.bjjd.datamodel.Allergyhistory;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;


/*
 * 过敏史的数据持久层DAO
 * 
 * 
 * 
*/
public class AllergyhistoryDAO {
	//查询过敏史记录方法
	public ArrayList searchallergyhistory(String str)throws Exception{
		ArrayList allergyhistorys=null;
		Session session=null;
		try
	    {
	    	
	    	SessionFactory factory = new Configuration().configure().buildSessionFactory();
	    	 session =factory.openSession();
	    	 allergyhistorys = (ArrayList)session.createQuery("from Allergyhistory where personid ="+str).list();
	    	session.beginTransaction().commit();
	    	return allergyhistorys;
	    }
	    catch(Exception e)
	    {
	    	throw e;
	    	//return users;
	    }
	    finally
	    {
	    	session.close();
	    }
	}
	//删除过敏史记录方法
	public void deleteallergyhistory(Allergyhistory 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 createallergyhistory(Allergyhistory 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 updateallergyhistory(Allergyhistory 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 + -
显示快捷键?