Does EclipseLink support ORDER BY FIELD(field, :values)

放肆的年华 提交于 2019-12-12 02:34:16

问题


MySQL supports queries such as:

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

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

When I try the following:

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

I receive the error:

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

回答1:


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

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.



来源:https://stackoverflow.com/questions/21014679/does-eclipselink-support-order-by-fieldfield-values

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!