SpringData like关键字不起作用
Posted 市井俗人
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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+"%";
以上是关于SpringData like关键字不起作用的主要内容,如果未能解决你的问题,请参考以下文章
Facebook REST API Like/UnLike 任何帖子都不起作用
Spring Data @CreatedDate 注释对我不起作用