When I compare the HQL there are differences between them, but I still haven't found out why that is....
Working HQL
Code:
select this_.CLI_SEQ as CLI1_3_1_, this_.CLI_FNAME as CLI2_3_1_, this_.CLI_LNAME as CLI3_3_1_, this_.CLI_OTH_NAME as CLI4_3_1_, this_.CLI_DOB as CLI5_3_1_, this_.CLI_SEX as CLI6_3_1_, this_.CLI_DT_CHNG as CLI7_3_1_, this_.CLI_STS_SEQ as CLI8_3_1_, this_.CLI_MNAME as CLI9_3_1_, this_.CLI_RACE_SEQ as CLI10_3_1_, this_.CLI_ETH_SEQ as CLI11_3_1_, this_.CLI_DT_OPEN as CLI12_3_1_, this_.CLI_DT_CLOSED as CLI13_3_1_, programact2_.PA_SEQ as PA1_8_0_, programact2_.PA_REFX_SEQ as PA2_8_0_, programact2_.PA_CLI_SEQ as PA3_8_0_, programact2_.PA_START_DT as PA4_8_0_, programact2_.PA_LAST_ACTIVITY_DT as PA5_8_0_, programact2_.PA_STATUS_CSX_SEQ as PA6_8_0_, programact2_.PA_CLOSE_DT as PA7_8_0_, programact2_.PA_STAFF_SEQ as PA8_8_0_ from SHS_CLIENTS this_ left outer join SHS_PROGRAM_ACTIVITY programact2_ on this_.CLI_SEQ=programact2_.PA_SEQ where exists (select pa_.PA_SEQ as y0_ from SHS_PROGRAM_ACTIVITY pa_ inner join SHS_REFERRED_CODES refcode1_ on pa_.PA_REFX_SEQ=refcode1_.REFX_SEQ where pa_.PA_CLI_SEQ=this_.CLI_SEQ and refcode1_.REFX_CODE=?)
Non-Working HQLCode:
select * from ( select this_.CLI_SEQ as CLI1_3_1_, this_.CLI_FNAME as CLI2_3_1_, this_.CLI_LNAME as CLI3_3_1_, this_.CLI_OTH_NAME as CLI4_3_1_, this_.CLI_DOB as CLI5_3_1_, this_.CLI_SEX as CLI6_3_1_, this_.CLI_DT_CHNG as CLI7_3_1_, this_.CLI_STS_SEQ as CLI8_3_1_, this_.CLI_MNAME as CLI9_3_1_, this_.CLI_RACE_SEQ as CLI10_3_1_, this_.CLI_ETH_SEQ as CLI11_3_1_, this_.CLI_DT_OPEN as CLI12_3_1_, this_.CLI_DT_CLOSED as CLI13_3_1_, programact2_.PA_SEQ as PA1_8_0_, programact2_.PA_REFX_SEQ as PA2_8_0_, programact2_.PA_CLI_SEQ as PA3_8_0_, programact2_.PA_START_DT as PA4_8_0_, programact2_.PA_LAST_ACTIVITY_DT as PA5_8_0_, programact2_.PA_STATUS_CSX_SEQ as PA6_8_0_, programact2_.PA_CLOSE_DT as PA7_8_0_, programact2_.PA_STAFF_SEQ as PA8_8_0_ from SHS_CLIENTS this_ left outer join SHS_PROGRAM_ACTIVITY programact2_ on this_.CLI_SEQ=programact2_.PA_SEQ where exists (select this0__.PA_CLI_SEQ as y0_ from SHS_PROGRAM_ACTIVITY this0__ where this0__.PA_CLI_SEQ=this_.CLI_SEQ and refcode1_.REFX_CODE=?) order by this_.CLI_SEQ asc ) where rownum <= ?