如何在jpa createquery中加入两个表?

时间:2013-08-28 10:02:57

标签: sql jpa netbeans

我想加入两张桌子,但我收到了错误。 我使用了这种语法:

Query qrec2=em.createQuery("Select o from OfPlanifie o Operateur w where o.idOpe =: w.idOpe");

但我收到了这个错误:

Caused by: Exception [EclipseLink-8025] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Syntax error parsing the query [Select o from OfPlanifie o Operateur w where o.idOpe =: w.idOpe], line 1, column 27: unexpected token [Operateur].
Internal Exception: NoViableAltException(80@[()* loopback of 477:9: (node= join )*])

我如何加入这两张桌子?

1 个答案:

答案 0 :(得分:0)

您在两个表OfPlanifie o, Operateur w

之间缺少逗号

此外,如果您要从OfPlanifie中选择所有列,则必须执行SELECT o.*而不是SELECT o