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

📄 famillydao.java

📁 是一个J2EE的项目,在eclipse下编译通过,应用struts,hibernate开源框架,界面不是很漂亮.
💻 JAVA
字号:
package com.bjjd.DAO;
import java.util.ArrayList;
import com.bjjd.datamodel.Familly;


import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

/*
 * 家庭数据持久层DAO
 * 
 */
public class FamillyDAO {
	//查询家庭记录方法
	public ArrayList searchfamilly(String str)throws Exception{
		ArrayList mainproblems=null;
		Session session=null;
		try
	    {
	    	
	    	SessionFactory factory = new Configuration().configure().buildSessionFactory();
	    	 session =factory.openSession();
	    	mainproblems = (ArrayList)session.createQuery("from Familly where personid ="+str).list();
	    	session.beginTransaction().commit();
	    	return mainproblems;
	    }
	    catch(Exception e)
	    {
	    	throw e;
	    	//return users;
	    }
	    finally
	    {
	    	session.close();
	    }
	}
	//删除家庭记录方法
	public void deletefamilly(Familly 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 createfamilly(Familly 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 updatefamilly(Familly 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 + -