EclipseLink(2.1.3 版)中 JQPL 中的 Oracle NVL 函数是否等效?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13678823/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Oracle NVL function equivalent in JQPL in EclipseLink (Version 2.1.3)?
提问by Ibram
I do this JPQL query
我做这个 JPQL 查询
SELECT e
FROM Expediente e
WHERE e.fechaBaja is null
ORDER BY e.idSituacion ASC,
e.idExpediente ASC
but when e.idSituacion
is null, eclipseLink not return this registry.
但是当e.idSituacion
为空时,eclipseLink 不返回此注册表。
How could i do this query with oracle function nvl
? Is Is EclipseLink 2.1.3 support this function?
我怎么能用 oracle 函数做这个查询nvl
?EclipseLink 2.1.3 是否支持这个功能?
SELECT nvl(e.idSituacion,' ')
FROM Expediente e
WHERE e.fechaBaja is null
ORDER BY e.idSituacion ASC,
e.idExpediente ASC
or
或者
SELECT e
FROM Expediente e
WHERE e.fechaBaja is null
and nvl(e.idSituacion,' ')
ORDER BY e.idSituacion ASC,
e.idExpediente ASC
Thank you.
谢谢你。
采纳答案by Ibram
It′s a eclipseLink Bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=294092.
这是一个 eclipseLink Bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=294092。
I need native sql, example http://tomaszdziurko.pl/2011/12/problem-withjpa-join-column-null-values-and-orderby/
我需要本机 sql,例如http://tomaszdziurko.pl/2011/12/problem-withjpa-join-column-null-values-and-orderby/
回答by Peter Bagyinszki
COALESCE
合并
I don't exactly see how it will help you, but you can use COALESCE
function: http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Querying/JPQL#Functions
我不知道它会如何帮助你,但你可以使用COALESCE
函数:http: //wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Querying/JPQL#Functions
(This is similar toNVL
, but NVL
is Oracle specific, COALESCE
is ANSI standard.)
(这类似于NVL
,但NVL
特定于Oracle,COALESCE
是 ANSI 标准。)
Order
命令
With ORDER BY e.idSituacion ASC
null values will be at the end of the results.
随着ORDER BY e.idSituacion ASC
空值将在结果的结尾。
If you want to have your null values first you can use NULLS FIRST
clause:
如果你想先有你的空值,你可以使用NULLS FIRST
子句:
ORDER BY e.idSituacion ASC NULLS FIRST
ORDER BY e.idSituacion ASC NULLS FIRST
(Only from Eclipselink 2.4)
(仅来自 Eclipselink 2.4)