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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 01:18:01  来源:igfitidea点击:

Oracle NVL function equivalent in JQPL in EclipseLink (Version 2.1.3)?

javaoraclefunctioneclipselink

提问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.idSituacionis 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 Peter Bagyinszki

COALESCE

合并

I don't exactly see how it will help you, but you can use COALESCEfunction: 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 NVLis Oracle specific, COALESCEis ANSI standard.)

(这类似于NVL,但NVL特定于Oracle,COALESCE是 ANSI 标准。)

Order

命令

With ORDER BY e.idSituacion ASCnull 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 FIRSTclause:

如果你想先有你的空值,你可以使用NULLS FIRST子句:

ORDER BY e.idSituacion ASC NULLS FIRST

ORDER BY e.idSituacion ASC NULLS FIRST

(Only from Eclipselink 2.4)

(仅来自 Eclipselink 2.4)