简体   繁体   中英

JPA 2.0 Sub select in JPA criteria query

How to write criteria query with subquery (use CriteriaBuilder construct method)?

  select t1.id,
       t1.name,
       (select count(t2.id) from table_name_2 t2 where t2.t1_id = t1.id) as   some_count
    from table_name t1

Thank in advance

编写方法相同,但使用实体类名称代替table_name。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM