0
我有一個問題,這個查詢在JPA:JPA查詢右連接上
String query= "SELECT pc.pcKey, c.id, c.pcName
FROM Computer c RIGHT JOIN c.pcKey pc ON c.pcKey = pc.pcKey
WHERE pc.pcKey IS NOT NULL AND pc.pk.idLaboratory = :laboratoryId";
這是錯誤消息我得到:
with clause can only reference columns in the driving table [SELECT pc.pcKey, c.id, c.pcName FROM com.want.ecdlejb.hibernate.model.Computer c RIGHT JOIN c.pcKey pc ON c.pcKey = pc.pcKey WHERE pc.pcKey IS NOT NULL AND pc.pk.idLaboratory = :laboratoryId]
at org.hibernate.hql.internal.ast.HqlSqlWalker$WithClauseVisitor.visit(HqlSqlWalker.java:508)
實體計算機類
@ManyToOne
@JoinColumn(name="pc_key", nullable=false)
private PcKey pcKey;
實體PcKey類
@OneToMany(mappedBy="pcKey")
private Set<Computer> computerses;
我讀到了這個錯誤的一些錯誤,但它是在2012年,我認爲他們已經修復它。任何人都知道如何正確地使這個查詢?
「pc.pk.idLaboratory」 不明白。 – ozgur
請你寫完整的實體。 – ozgur
對不起應該是pc.idLaboratory – Faron