protected List getData() {
List list = null;
Transaction tx = null;
try {
session = HibernateUtil.currentSession();
tx = session.beginTransaction();
Query q = null;
String hql = "from WqDcShujuVpnServiceInfo shuzuvpnservice where 1=1"
q = session.createQuery(hql);
q = setParameter(q);
list = q.list();
tx.commit();
} catch (HibernateException e) {
if (tx != null)
tx.rollback();
throw e;
} finally {
try {
HibernateUtil.closeSession();
} catch (HibernateException e1) {
e1.printStackTrace();
}
}
return list;
}
本文介绍了一个使用Hibernate框架进行数据库查询的示例代码。该示例展示了如何通过Hibernate创建查询对象并设置参数,从WqDcShujuVpnServiceInfo表中获取数据。
2171

被折叠的 条评论
为什么被折叠?



