代码之家  ›  专栏  ›  技术社区  ›  Renaud is Not Bill Gates

在JPA标准API中使用公共表表达式(CTE)

  •  0
  • Renaud is Not Bill Gates  · 技术社区  · 6 年前
    WITH cte AS
    (
    select
            A.A_ID,
            B.Lib,
            A.Lib,
            C.Lib,
            (SELECT count(*) FROM X WHERE A.A_ID = X.A_ID) AS countX,
            (SELECT count(*) FROM Y WHERE A.A_ID = Y.A_ID) AS countY,
            (SELECT count(*) FROM Z WHERE A.A_ID = Z.A_ID) AS countZ
        from
            A
        left outer join
            C
                on A.C_ID=C.C_ID
        left outer join
            B
                on A.B_ID=B.B_ID
    ) select * from cte where countX = 2 AND countY = 3
        Order BY 
        countZ DESC;
    

    我知道如何在CTE中创建sql查询,但我不知道如何在JPA Criteria API中创建CTE( WITH cte AS (...) SELECT * FROM cte ).

    0 回复  |  直到 6 年前
    推荐文章