Java:JPQL 搜索相似字符串
有哪些方法可以让JPQL匹配相似的字符串?
类似我的意思是:
- 包含:在匹配实体的字符串中找到搜索字符串
- 不区分大小写
- 小拼写错误:例如“arow”匹配“arrow”
我怀疑前两个会很容易,但是,我希望对最后一个有帮助一个
谢谢
What methods are there to get JPQL to match similar strings?
By similar I mean:
- Contains: search string is found within the string of the matches entity
- Case-insensitive
- Small mispellings: e.g. "arow" matches "arrow"
I suspect the first two will be easy, however, I would appreciate help with the last one
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
前两个确实很容易使用 完成
LIKE
和LOWER
或UPPER
关键字。最后一项很难做到,因为它要求您定义两个字符串的相似程度。在 JPQL 中没有基本关键字可以轻松做到这一点(据我所知)。您可以使用诸如 Levenshtein distance 之类的算法来确定是否存在小拼写错误(距离为 1或 2)。但这在 JPQL 中并没有完成......The first two are indeed easy to do using the
LIKE
andLOWER
orUPPER
keywords. The last one is very hard to do, since it requires you to define how similar two strings need to be. There is no basic keyword to do this easily in JPQL (as far as I know). You could use an algorithm like Levenshtein distance to determine if there is a small mispelling (distance of 1 or 2). This is not done in JPQL though...