📄 allergyhistorydao.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -