需要休眠函数返回一个子串的索引 [英] Need hibernate function that returns the index of a substring

查看:64
本文介绍了需要休眠函数返回一个子串的索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要在hibernate中返回一个指定子字符串索引的函数,我将在 substring 函数中使用该索引,例如考虑以下休眠查询:

I want a function in hibernate that returns the index of a specified substring, i will use that index in substring function, for example consider this hibernate query:

from PersonObject m where substring(m.description,44,4) BETWEEN :minnum and :maxnum

我想使用请求的函数而不是起始索引 44 来动态获取起始索引,因为该位置对于一个字符串到另一个字符串而言会有所不同

i want to use the requested function instead of the start index 44 to dynamically get the start index as this position varies for one string to another

推荐答案

JPQL函数开始位置为定位:

JPQL function to get start position is LOCATE:

LOCATE(string_primary,string_primary [,simple_arithmetic_expression])

LOCATE(string_primary, string_primary[, simple_arithmetic_expression])

由于HQL或多或少是JPQL的超集,因此它当然也适用于HQL.

Because HQL is more or less superset of JPQL, it of course works also in HQL.

这篇关于需要休眠函数返回一个子串的索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆