SpringData like关键字不起作用

2021-07-09 17:06

阅读:544

标签: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


评论


亲,登录后才可以留言!