EclipseLink是否支持ORDER BY FIELD(字段,:值) [英] Does EclipseLink support ORDER BY FIELD(field, :values)

查看:230
本文介绍了EclipseLink是否支持ORDER BY FIELD(字段,:值)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MySQL支持以下查询:

MySQL supports queries such as:

SELECT id FROM users WHERE id IN(3,4,8,1) ORDER BY FIELD(id, 3,4,8,1);

EclipseLink是否支持此查询(不恢复原生查询)?

Does EclipseLink support this query (without reverting to a native query)?

当我尝试以下操作时:

Select id from User user where user.id in :ids ORDER BY FIELD(user.id, :ids)

我收到错误消息:

Syntax error parsing the query ... line 1, column 98: unexpected token [(].


推荐答案

ORDER BY FIELD(字段,:值) JPA(JQL)或EclipseLink不支持。

ORDER BY FIELD(field, :values) is not supported by JPA (JQL) or EclipseLink.

JPA确实提供了一种执行本机查询的机制。您可以创建一个本机查询来调用类似于但是,你的描述当然是不可移植的。

JPA does provide a mechanism to execute native queries. You could create a native query to invoke a query similar to that in your description, however, it of course, would not be portable.

这篇关于EclipseLink是否支持ORDER BY FIELD(字段,:值)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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