2009-05-27 68 views
0

是否有可能將此sql語句翻譯爲CreateCriteria,其次是NHibernate涉及ORDER BY COALESCENHibernate COALESCE

SELECT obs1.OBSLOPNR, obs1.LOKALLOPNR, obs2.OBSLOPNR, obs2.LOKALLOPNR 
FROM 
    (SELECT * FROM OBS WHERE OBS.LOKALLOPNR = 9) AS obs1 
FULL OUTER JOIN 
    (SELECT * FROM OBS WHERE OBS.LOKALLOPNR = 8) AS obs2 
ON obs1.ARTLOPNR = obs2.ARTLOPNR 
ORDER BY COALESCE(obs1.OBSLOPNR, obs2.OBSLOPNR) 
+0

像這樣的情況,我們將始終使它成爲一個存儲過程,然後使用session.getNameQuery()來調用該過程。我們爲什麼不讓事情變得簡單? – 2017-08-21 18:26:11

回答

0

沒有內置支持。但是,您可以創建自己的訂單類。 Here is a good example

您可以創建一個接受任何sql字符串的類,也可以嘗試創建一個CoalesceOrder類。