方式一:
String hql = "from InventoryTask it where it.orgId=:orgId"; Session session = getSession(); Query query=session.createQuery(hql); query.setString("orgId",orgId); List list = query.list(); if(list!=null&&list.size()!=0){ return (InventoryTask)list.get(0); }else{ return null; }
本文介绍了两种使用HQL(Hibernate Query Language)从数据库检索特定记录的方法。第一种方式通过命名参数设置查询条件,第二种方式采用位置占位符来传递参数值。这两种方法均实现了根据组织ID查询InventoryTask对象。

1860

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



