如何使用 CriteriaBuilder 编写以下 sql 查询

How to write the following sql query with CriteriaBuilder

我想将查询写入 Criteria Builder 时遇到问题。或者,如果更好地编写 SQL 查询以便更容易在条件生成器中编写?

select
    DATA_TABLE.*, M_ORDER.CODE 
from
    ( select
        log0_.MSG_ID,
        login1_.NAME,
        log0_.METHOD,
        logpa2_.VALUE
    from
        M_LOG log0_
    inner join
        M_LOG_INTER login1_ 
            on log0_.ID_INTER=login1_.ID_INTER 
    inner join
        M_PARAMS logpa2_ 
            on log0_.MS_ID=logpa2_.MS_ID 
    where
        logpa2_.KEY='id'
    ) DATA_TABLE, M_ORDER
WHERE
    data.value = m_order.ID and
    rownum <= 10; 

重组(简化)SQL 查询:

select
    * 
from
    ( select
        log0_.MSG_ID,
        login1_.NAME,
        order3_.CODE,
        log0_.METHOD
        logpa2_.VALUE,
    from
        M_LOG log0_,
        M_LOG_INTER login1_,
        M_LOG_PARAMS logpa2_,
        M_ORDER order3_ 
    where
        logpa2_.KEY='id' 
        and logpa2_.VALUE=order3_.ID 
        and log0_.MS_ID=logpa2_.MS_ID 
        and log0_.ID_INTER=login1_.ID_INTER
    ) 
where
    rownum <= 10;

并且使用 CriteriaBuilder 查询很容易。