Eclipselink是否支持包含正则表达式的查询? [英] Does Eclipselink support queries containing regular expression?

查看:99
本文介绍了Eclipselink是否支持包含正则表达式的查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到像MySQL这样的DBMS支持包含正则表达式的查询. Eclipselink支持吗?

I've seen that DBMS like MySQL supports query containing regular expressions. Does Eclipselink support this?

我必须检索具有与某些正则表达式匹配的String属性的实体

I have to retrieve entities having some String attribute matching some regular expression as

SELECT X FROM Person X WHERE X.name <some keyword> (A-Z)*

推荐答案

MySQL使用REGEX或RLIKE进行正则表达式查询. JPQL不支持这些运算符,因此您可以使用本机SQL查询.

MySQL uses REGEX or RLIKE for regular expression queries. JPQL does not support these operators, so you can use a native SQL query.

在EclipseLink中,您可以为它们定义自己的ExpressionOperator,并在Expression查询中使用它,但当前不适用于JPQL. JPQL确实支持使用FUNC调用数据库函数,但是它们的语法与函数不同.您可以扩展MySQLPlatform以使像我们这样的REGEX或RLIKE.

In EclipseLink you could define your own ExpressionOperator for these, and use it in an Expression query, but not currently with JPQL. JPQL does support calling database functions using FUNC, but these have different syntax than functions. You could extend the MySQLPlatform to make #like us REGEX or RLIKE.

请为此在EclipseLink上记录一个错误.现在,大多数数据库都支持正则表达式,因此该支持应该在JPQL中可用.

Please log a bug for this on EclipseLink. Most databases now support regex, so this support should be available in JPQL.

这篇关于Eclipselink是否支持包含正则表达式的查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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