我怎麼能說出下面的MySQL查詢在JPQL轉換MySQL查詢JPQL查詢
select * from Price WHERE `valueDate` = (SELECT MAX(`valueDate`) FROM Price) and fundId = 2930
我曾嘗試如下:這種辦法
"select a from Price a where a.valueDate = select MAX(a.valueDate) and a.fund.id = :" +Price.QUERY_PARAM_FUND_ID
,但得到的錯誤:
Caused by: <openjpa-2.3.0-r422266:1540826 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: "Encountered "MAX" at character 50, but expected: ["AND", "GROUP", "HAVING", "OR", "ORDER", <EOF>]." while parsing JPQL "select a from Price a where a.valueDate = select MAX(b.valueDate) from Price b and a.fund.id = :fundId"
請顯示一些努力,顯示你已經嘗試過。人們會更熱衷於幫助,而你的問題更可能保持不變。 – Magnilex 2014-09-30 11:21:19
你好,我已經添加了我的嘗試。感謝您的回覆 – 2014-09-30 11:24:45
錯誤是什麼?你能把它粘貼在這裏嗎? – 2014-09-30 11:28:08