How to create appropriate HQL from SQL:
SQL (working):
Code:
select iire.instrumentId, iire.basePoint
, (select max(ih.value) from instrument_history_tbl ih where ih.instrumentId = iire.interestRateId) as value
from instrument_interestr_entry_tbl iire
where iire.instrumentId=758
HQL (not working):
Code:
select iire.instrumentId, iire.basePoint
, (select max(ih.value) from InstrumentHistory ih where ih.instrumentId = iire.interestRateId) as value
from InstrumentInterestRateEntry iire
where iire.instrumentId=758
HQL raises exception:
1 errors occurred while listing (and calling getPathNames).
net.sf.hibernate.QueryException: aggregate function expected before ( in SELECT [select iire.instrumentId, iire.basePoint
, (select max(ih.value) from com.pxpfs.excom2.finance.domainmodel.InstrumentHistory ih where ih.instrumentId = iire.interestRateId) as value
from com.pxpfs.excom2.finance.domainmodel.InstrumentInterestRateEntry iire
where iire.instrumentId=758
]