任何人都可以解释为什么会抛出JPQL异常吗?
Query q = em.createQuery("select object(o) from SiteMember as o order by size(o.memberThread) desc");
memberThread refer a list.
答案 0 :(得分:0)
很可能是因为您使用了JPA实现(也是数据库供应商可能很重要),该实现没有针对此类查询的供应商扩展。根据JPA 2.0,以下类型的值可以在ORDER BY
中使用:
1.A state_field_path_expression that evaluates to an orderable state field of an
entity or embeddable class abstract schema type designated in the SELECT clause
by one of the following:
• a general_identification_variable
• a single_valued_object_path_expression
2.A state_field_path_expression that evaluates to the same state field of the same
entity or embeddable abstract schema type as a state_field_path_expression in the
SELECT clause
3.A result_variable that refers to an orderable item in the SELECT clause for which
the same result_variable has been specified. This may be the result of an
aggregate_expression, a scalar_expression, or a state_field_path_expression in the
SELECT clause.
您的查询适用于EclipseLink(2.3.2)和MySQL。