insert方法
public void insert(Object o){
Session session = HibernateSessionFactory
Transaction t = session
session
mit();
HibernateSessionFactory
}
delete方法
public void delete(Object o
Session session = HibernateSessionFactory
Transaction t = session
Object o = session
if(o!=null){
session
}
mit();
HibernateSessionFactory
}
update方法
public void update(Object o
Session session = HibernateSessionFactory
Transaction t = session
session
mit();
HibernateSessionFactory
}
基於HQL的通用select方法
public ArrayList select(String sql){
Session session = HibernateSessionFactory
Query query = createQuery(sql);
List list = query
HibernateSessionFactory
return (ArrayList)list;
}
基於SQL的通用select方法
public ArrayList select(String sql) throws Exception{
Session session = HibernateSessionFactory
Connection con = nnection();
PreparedStatement pstmt = con
ResultSet rs = pstmt
ResultSetMetaData rsmd = rs
Hashtable ht = null;
ArrayList array = new ArrayList();
while(rs
ht = new Hashtable();
for(int i=
ht
}
array
}
HibernateSessionFactory
return array;
}
From:http://tw.wingwit.com/Article/program/Java/ky/201311/28011.html