0
我在Participant和抽象實體之間有OneToOne關係。我想查詢具有摘要的參與者。所以,我創建了以下查詢:JPA:對查詢鍵anyOf()無效使用
@NamedQuery(name = Participant.FIND_ABSTRACT, query = "SELECT p FROM Participant p WHERE p.abstract_ IS NOT EMPTY ORDER BY p.email"),
....
....
@OneToOne
@JoinColumn
private Abstract abstract_;
從Abstract.java:
@OneToOne(mappedBy="abstract_")
private Participant participant;
當我嘗試使用它:
public List<Participant> getUploadedAbstract() {
TypedQuery<Participant> query = em.createNamedQuery(Participant.FIND_ABSTRACT, Participant.class);
return query.getResultList();
}
我獲得:
Caused by: Exception [EclipseLink-6071] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.QueryException
Exception Description: Invalid use of anyOf() for a query key [org.eclipse.persistence.mappings.OneToOneMapping[abstract_]] not representing a to-many relationship in an expression. Use get() rather than anyOf().
at org.eclipse.persistence.exceptions.QueryException.invalidUseOfAnyOfInExpression(QueryException.java:738)
at org.eclipse.persistence.internal.expressions.QueryKeyExpression.validateNode(QueryKeyExpression.java:894)
at org.eclipse.persistence.expressions.Expression.normalize(Expression.java:2985)
at org.eclipse.persistence.internal.expressions.DataExpression.normalize(DataExpression.java:342)
at org.eclipse.persistence.internal.expressions.QueryKeyExpression.normalize(QueryKeyExpression.java:612)
at org.eclipse.persistence.internal.expressions.RelationExpression.normalize(RelationExpression.java:605)
at org.eclipse.persistence.internal.expressions.SQLSelectStatement.normalize(SQLSelectStatement.java:1300)
at org.eclipse.persistence.internal.expressions.SubSelectExpression.normalizeSubSelect(SubSelectExpression.java:197)
at org.eclipse.persistence.internal.expressions.ExpressionNormalizer.normalizeSubSelects(ExpressionNormalizer.java:93)
... ...
我哪裏錯了?
你,你已經準備好了。謝謝大家。 –