English 中文(简体)
JPQL/Hibernate各栏
原标题:Ordering by varying columns in JPQL/Hibernate

我有一个会议桌。 每届会议都有“会议启动——时间”和“会议——时间”。 虽然本届会议开幕,但最后时间是空的。 我想列举会议清单,并按以下逻辑排列:

  1. If the session is open (no end time), order by the start time.
  2. If the session is closed, order by the end time.

类似:

 ORDER BY (session_end_time == null) ? session_start_time : session_end_time

I m使用JPA和JPQL进行询问,并利用Hibernate执行。 你们会建议什么?

www.un.org/Depts/DGACM/index_spanish.htm 我不想在选任考试委员会中加入考试和测验科,而是保持清扫,以便我获得一份届会清单,而不需要额外的领域。

最佳回答

页: 1

nvl是甲骨质功能。 我确信,管理人的职能与其他房舍管理处一样。

Found this one for hibernate: nvl in HIBERNATE: How to simulate NVL in HQL

ORDER BY: https://forum.hibernate.org/viewtopic.php?f=25&t=997220&start=0

问题回答

页: 1

ORDER BY CASE 
    WHEN session_end_time IS NULL THEN session_start_time 
    ELSE session_end_time 
END 

房舍管理处的工作? 这并没有增加一个领域。

否则,你就可以在带宽的盘点中进行计算,但是没有在最后的<代码>中进行计算。 缩略语 条款:

SELECT field1, field2 FROM (
    SELECT field1, field2, CASE WHEN session_end_time... END AS dummyfield
) Q
ORDER BY Q.dummyfield




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签