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