Spring executefind method: callback query operation
•
Java
executeFind(HibernateCallback action)
Example
public List getSmallUser(final Integer ID){
HibernateTemplate htm = getHibernateTemplate();
final String sql = "FROM TbUser u where u.age<18"; //生成一条sql语句
List list = htm.executeFind(new HibernateCallback(){
public Object doInHibernate(Session session)throws HibernateException,sqlException{
Query query = session.createQuery(sql);
List list = query.list();
return list;
}
}); //创建一个List集合接收查询结果
return list;
}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
