码迷,mamicode.com
首页 > 编程语言 > 详细

SpringData like关键字不起作用

时间:2018-08-31 14:05:12      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:abstract   span   模糊   rem   oid   简单   publish   tag   rom   

使用springdata简单查询时,like关键字不起作用

Hibernate: select article0_.oId as oId1_2_, 
article0_.articleAbstract as articleA2_2_, 
article0_.articleAuthorEmail as articleA3_2_, 
article0_.articleCommentCount as articleC4_2_, 
article0_.articleCommentable as articleC5_2_, 
article0_.articleContent as articleC6_2_, 
article0_.articleCreateDate as articleC7_2_, 
article0_.articleEditorType as articleE8_2_, article0_.articleHadBeenPublished as articleH9_2_, 
article0_.articleIsPublished as article10_2_, 
article0_.articlePermalink as article11_2_, 
article0_.articlePutTop as article12_2_, 
article0_.articleRandomDouble as article13_2_, 
article0_.articleSignId as article14_2_, 
article0_.articleTags as article15_2_, 
article0_.articleTitle as article16_2_, 
article0_.articleUpdateDate as article17_2_, 
article0_.articleViewCount as article18_2_, 
article0_.articleViewPwd as article19_2_ 
from Article article0_ where 
article0_.articleTitle like ? or 
article0_.articleAbstract like ? or 
article0_.articleContent like ?

由查询的语句可知,这里虽然使用了like关键字,但是没有进行模糊匹配

解决办法:

将传入的关键字转化为加入模糊匹配字符,“%” 或者 “*”

 keyword="%"+keyword+"%";

SpringData like关键字不起作用

标签:abstract   span   模糊   rem   oid   简单   publish   tag   rom   

原文地址:https://www.cnblogs.com/fdzang/p/9565322.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!