2011-12-17 28 views
0

我想知道合併多個領域如果有下面寫JPQL - 在IN表達

select o from entity1 o where (o.field1, o.field2) IN (select value1, value2 from ...) 

類似的SQL查詢工作在Oracle 10g中一個類似於一個JPQL語句的方式。然而,在eclipselink,我得到這個錯誤:

syntax error at [,]. 
Internal Exception: MismatchedTokenException(81!=84) 
at org.eclipse.persistence.exceptions.JPQLException.syntaxErrorAt(JPQLException.java:362) 
at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser.handleRecognitionException(JPQLParser.java:301) 
at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser.addError(JPQLParser.java:242) 
at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser.reportError(JPQLParser.java:359) 

任何幫助表示讚賞。

謝謝, KL

回答

0

這種查詢不被JPA規範覆蓋(均未1也不2)。但是,Hibernate確實支持它。

+0

感謝您的信息。 – 2011-12-17 15:52:23

0

您可以使用本機SQL查詢來完成此操作,也可以使用連接而不是子查詢。

EclipseLink在表達式查詢中支持這一點,但目前在JPQL中不支持。 (不是所有的數據庫都支持這個)