这是打印出他自动转化的HQL
Hibernate:
WITH query AS (select
this_.id as id8_0_,
this_.code as code8_0_,
this_.create_by as create3_8_0_,
this_.create_date as create4_8_0_,
this_.name_cn as name5_8_0_,
this_.name_en as name6_8_0_,
this_.update_by as update7_8_0_,
this_.update_date as update8_8_0_,
(select
stuff((select
','+c.name_cn,
ROW_NUMBER() OVER (
ORDER BY
CURRENT_TIMESTAMP) as hibernate_row_nr
from
sys_country c
where
c.id in (select
b.country_id
from
sys_region_country b
where
b.region_id = (select
a.id
from
sys_region a
where
a.id=a.id))this_.for this_.xml path('')),1,1,'')) as formula0_0_
from
sys_region this_) SELECT
*
FROM
query
WHERE
hibernate_row_nr >= ?
AND hibernate_row_nr < ?
这是我写的SQL
SELECT STUFF((select ','+NAME_CN from SYS_COUNTRY c WHERE c.ID in (select b.COUNTRY_ID from SYS_REGION_COUNTRY b WHERE b.REGION_ID = (select a.ID from SYS_REGION a WHERE a.ID=a.ID))
FOR XML PATH('')), 1, 1, '')