2011-12-17 65 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中不支持。 (不是所有的数据库都支持这个)