communityaddressdao.java
来自「是一个J2EE的项目,在eclipse下编译通过,应用struts,hibern」· Java 代码 · 共 91 行
JAVA
91 行
package com.bjjd.DAO;
import java.util.ArrayList;
import com.bjjd.datamodel.Communityaddress;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
/*
* 社区地址数据持久层DAO
*
*
*/
public class CommunityaddressDAO {
//查询功能DAO类
public ArrayList searchcommunityaddress(String str1,String str2,String str3)throws Exception{
ArrayList communityaddress=null;
Session session=null;
try
{
SessionFactory factory = new Configuration().configure().buildSessionFactory();
session =factory.openSession();
communityaddress = (ArrayList)session.createQuery("from Communityaddress where level1 like '%"+str1
+"%' and level2 like '%"+str2+"%' and level3 like '%"+str3+"%' ").list();
session.beginTransaction().commit();
return communityaddress;
}
catch(Exception e)
{
throw e;
//return users;
}
finally
{
session.close();
}
}
//删除功能DAO类
public void deletecommunityaddress(Communityaddress ca)throws Exception{
Session session=null;
try{
SessionFactory factory = new Configuration().configure().buildSessionFactory();
session =factory.openSession();
session.delete(ca);
session.beginTransaction().commit();
}
catch(Exception e){
throw e;
}
finally
{
session.close();
}
}
//新建功能DAO类
public void createcommunityaddress(Communityaddress ca)throws Exception{
Session session=null;
try{
SessionFactory factory = new Configuration().configure().buildSessionFactory();
session =factory.openSession();
session.save(ca);
session.beginTransaction().commit();
}
catch(Exception e){
throw e;
}
finally
{
session.close();
}
}
//修改功能DAO类
public void updatecommunityaddress(Communityaddress ca)throws Exception{
Session session=null;
try{
SessionFactory factory = new Configuration().configure().buildSessionFactory();
session =factory.openSession();
session.update(ca);
session.beginTransaction().commit();
}
catch(Exception e){
throw e;
}
finally
{
session.close();
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?