SpringData like关键字不起作用

使用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+"%";
posted @ 2018-08-31 13:30  市井俗人  阅读(475)  评论(0编辑  收藏  举报