我想用JPA2标准查询表达本机SQL查询。 这个查询已经有效了,但我还是没能使用JPA2来获取它。 我认为主要是因为我缺乏经验。 我在这里粘贴SQL,也许你的专家可以帮我弄明白:
SELECT * FROM
OWNING_POINTS o1
JOIN
(SELECT conversationId, count(*) as nOfMsg
FROM OWNING_POINTS
GROUP BY conversationId) as o2
ON o1.conversationId = o2.conversationId
LEFT JOIN
(SELECT id, created as newerUnreadMessage
FROM OWNING_POINTS
WHERE `read`=0) as o3
ON o1.id = o3.id " +
WHERE o1.owner_user_id=?
ORDER BY newerUnreadMessage DESC, nOfMsg DESC
非常感谢。