hibernate mysql 模糊查询_Hibernate 模糊查询 如何通过setProperties方法绑定参数

补充一下吧:我在一个controller函数里面要这样调用:

@RequestMapping("/complexFind")

public void complexFind(ComplexSearchForm searchForm,HttpServletRequest request,

HttpServletResponse response) throws Exception {

page=ServletRequestUtils.getIntParameter(request, "page", 1);//默认值为1

rows=ServletRequestUtils.getIntParameter(request, "rows", 0);

String hql=bookService.getCompleSearchHQL(searchForm);

books=bookService.find(hql,searchForm, page, rows);

//省略。。。

}

@Override

public String getCompleSearchHQL(ComplexSearchForm searchForm) {

String hql="from Book as book where 1=1 ";//前台已做验证,不能提交空的查询条件

if(searchForm.getName()!=null){

hql+="and book.BookName like :Name ";

}

if(searchForm.getAuthor()!=null){

if(searchForm.getName()!=null){

hql+=searchForm.getLogic1()+"book.Author like :Author ";

}else{

hql+="and book.Author like :Author ";

}

}

if(searchForm.getSeries()!=null){

if(searchForm.getAuthor()!=null){

hql+=searchForm.getLogic2()+"book.Series like :Series ";

}else{

if(searchForm.getName()!=null){

hql+=searchForm.getLogic1()+"book.Series like :Series ";

}else{

hql+="and book.Series like :Series ";

}

}

}

return hql;

}

现在就是怎么使用setProperties方法 和通配符 %

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值