Is JPA subquery in FROM clause possible?

前端 未结 1 1077
醉话见心
醉话见心 2020-12-17 05:44

I\'m having a little problem with JPA. Consider this scenario:

Table A (id_a) | Table B (id_b, id_a)

What I need is a query

相关标签:
1条回答
  • 2020-12-17 06:26

    JPA does not support sub-selects in the FROM clause but EclipseLink 2.4 current milestones builds does have this support.

    See, http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Querying/JPQL#Sub-selects_in_FROM_clause

    You can probably rewrite the query with just normal joins though.

    Maybe,

    Select a, size(a.bs) from A a
    

    or

    Select a, count(b) from A a join a.bs b group by a
    
    0 讨论(0)
提交回复
热议问题