1
我試圖創建一個@NamedQuery
將包含以下相關子查詢:JPA @NamedQuery相關子查詢
@NamedQuery(name = "Drcomments.findByOrderDesc", query = " SELECT a FROM (SELECT ROWNUMBER() OVER(ORDER BY d.drcommentsPK.commentSecondaryCode DESC) AS EL_ROWNM , d.drcommentsPK.commentSecondaryCode , d.commentSecondaryCodeDescription FROM Drcomments d WHERE d.drcommentsPK.commentPrimaryCode = 1) a WHERE a.EL_ROWNM < 4 and a.EL_ROWNM > 0 ")})
的問題是,我得到這個錯誤:
"Exception [EclipseLink-8025] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Syntax error parsing the query [Drcomments.findByOrderDesc: SELECT a FROM (SELECT ROWNUMBER() OVER(ORDER BY d.drcommentsPK.commentSecondaryCode DESC) AS EL_ROWNM , d.drcommentsPK.commentSecondaryCode , d.commentSecondaryCodeDescription FROM Drcomments d WHERE d.drcommentsPK.commentPrimaryCode = 1) a WHERE a.EL_ROWNM < 4 and a.EL_ROWNM > 0 ], line 1, column 15: unexpected token [(].
Internal Exception: org.eclipse.persistence.internal.jpa.parsing.jpql.InvalidIdentifierException"
不@NamedQuery支持相關的subquerys?如果是這樣, 如何創建一個將執行此類查詢的命名查詢?
感謝提前。