HQL子字符串的最后x个字符 [英] HQL substring last x characters
本文介绍了HQL子字符串的最后x个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对Hibernate还是很陌生,我想获取字符串的最后N个字符.我找到了substring方法,但这并没有真正帮助:(
I am quite new to Hibernate, and I would like to get the last N characters of a string. I found the substring method, but that didn't really help :(
有人有什么主意吗?
TIA
推荐答案
我实际上使用子字符串对其进行了修复.我忘记了我可以使用参数.我做了类似的事情:
I actually fixed it using substring. I forgot that I can use parameters. I did something like:
Query q = " .. where substring (field, :offset, :length) = something_else"
q.setParameter("offset", field.length() - N + 1);
q.setParameter("length", N);
这篇关于HQL子字符串的最后x个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文