为什么 JPQL 表达式不能导航到作为集合的关系字段之外?
Why JPQL expressions cannot navigate beyond relationship fields that are collections?
Excerpt from Java EE 7 tutorial:
SELECT DISTINCT p FROM Player p, IN (p.teams) AS t WHERE t.city = :city
Expressions cannot navigate beyond (or further qualify) relationship
fields that are collections. In the syntax of an expression, a
collection-valued field is a terminal symbol. Because the teams field
is a collection, the WHERE clause cannot specify p.teams.city (an
illegal expression).
为什么表达式不能导航到作为集合的关系字段之外?
我没有设计语言,我当然可以错过更重要的原因,但恕我直言,这没有多大意义:p.teams.city
读作 "the city
property of the teams
property of p
"。但是 teams
是一个集合。并且集合没有任何 city
属性.
这至少是记住这不是有效 JPQL 的好方法。
Excerpt from Java EE 7 tutorial:
SELECT DISTINCT p FROM Player p, IN (p.teams) AS t WHERE t.city = :city
Expressions cannot navigate beyond (or further qualify) relationship fields that are collections. In the syntax of an expression, a collection-valued field is a terminal symbol. Because the teams field is a collection, the WHERE clause cannot specify p.teams.city (an illegal expression).
为什么表达式不能导航到作为集合的关系字段之外?
我没有设计语言,我当然可以错过更重要的原因,但恕我直言,这没有多大意义:p.teams.city
读作 "the city
property of the teams
property of p
"。但是 teams
是一个集合。并且集合没有任何 city
属性.
这至少是记住这不是有效 JPQL 的好方法。