如何在JPQL中像任何人一样调用PostgreSQL函数 [英] How to call 'like any' PostgreSQL function in JPQL

查看:210
本文介绍了如何在JPQL中像任何人一样调用PostgreSQL函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下一个问题: 我有要过滤的名称列表.问题是我没有全名(因为我是从ui收到的),例如,我有此array = ['Joh',' Michae'].

I have next issue: I have list of names, based on which I want to filter.The problem is that I have not full names(Because I'm receiving them from ui), and I have, for example, this array= ['Joh', 'Michae'].

因此,我想基于此数组进行过滤.

So, I want to filter based on this array.

我在PostgreSQL中编写了查询

I wrote query in PostgreSQL

select * from q_ob_person where name  like any (array['%Хомяченко%', '%Вартопуз%']);

我想问一下如何编写JPQL查询.

And I want to ask how to write JPQL query gor this.

是否可以像JPQL一样调用postgresql函数?

Is there an option to call postgresql function like any from JPQL?

推荐答案

JPA 2.1允许使用调用任何SQL函数

JPA 2.1 allows invocation of any SQL function using

FUNCTION(sqlFuncName, sqlArgs)

所以您可能会做类似 的事情(请注意,您从未尝试过这种喜欢的人",只是随便玩吧)

So you could likely do something like (note never tried this LIKE ANY you refer to, just play around with it)

FUNCTION("LIKE", FUNCTION("ANY", arrayField))

很明显,通过调用特定于RDBMS的SQL函数,您将失去数据库独立性(如果这很重要).

Obviously by invoking SQL functions specific to a particular RDBMS you lose database independence (in case that's of importance).

这篇关于如何在JPQL中像任何人一样调用PostgreSQL函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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