У меня есть некоторый код гибернации, как показано ниже.
@ManyToOne(fetch = FetchType.LAZY)
@JoinFormula(value = "(SELECT MAX(status.id) KEEP (DENSE_RANK LAST ORDER BY last_update_date desc) from C_Status status WHERE status.plan_run_id = id)")
Но спящий режим по умолчанию добавляется, как показано ниже.
(SELECT
MAX(status.id) planrun0_.KEEP (planrun0_.DENSE_RANK planrun0_.LAST
ORDER BY
planrun0_.last_update_date desc)
from
C_Status status
WHERE
status.plan_run_id = planrun0_.id) as formula3_
Любая идея, как решить проблему.
Полный SQL от Hibernate ниже.
select
*
from
( select
planrun0_.id as id1_38_,
planrun0_.created_by as created_by2_38_,
planrun0_.creation_date as creation_date3_38_,
planrun0_.last_updated_by as last_updated_by4_38_,
planrun0_.last_update_date as last_update_date5_38_,
planrun0_.last_update_login as last_update_login6_38_,
planrun0_.version as version7_38_,
planrun0_.tenant_id as tenant_id8_38_,
planrun0_.plan_id as plan_id10_38_,
planrun0_.run_type as run_type9_38_,
(SELECT
MAX(status.id) planrun0_.KEEP (planrun0_.DENSE_RANK planrun0_.LAST
ORDER BY
planrun0_.last_update_date desc)
from
C_Status status
WHERE
status.plan_run_id = planrun0_.id) as formula3_
from
c_plan planrun0_
where
planrun0_.run_type=?
and planrun0_.tenant_id=?
order by
planrun0_.id asc )
where
rownum <= ?