Zer01ne 2016-12-26 08:39 采纳率: 0%
浏览 1004

hibernate4还能条件查询怎么玩,有没有api,求助。

condition封装的是:and...?..?..?
params封装的是参数

public List findAll(String condition, Object[] params, int startIndex, int pageSize) {
Session session = sessionFactory.getCurrentSession();
String hql = "from CrmCourseType where 1=1 "+condition;
Query query = session.createQuery(hql);
query.setFirstResult(startIndex);
query.setMaxResults(pageSize);
//这里我应该怎么写才能把参数注入
query.set。。。。。
return query.list();
}

  • 写回答

2条回答 默认 最新

  • 云晴 2016-12-26 10:01
    关注

    String hql = "from CrmCourseType where condition=?;
    query.setString(0,condition);

    评论

报告相同问题?