I need to convert this SQL query to HQL
select
*
from
( select
routemaste0_.ROUTE_ID as col_0_0_,
routemaste0_.ROUTE_CODE as col_1_0_,
routemaste0_.START_PLACE_ID as col_2_0_,
routemaste0_.END_PLACE_ID as col_3_0_,
routemaste0_.IS_ACTIVE as col_4_0_,
routemaste0_.LINKED_ROUTE as col_5_0_
from
OPRS_ROUTE_MASTER routemaste0_
inner join OPRS_ROUTE_HALTS routehalts0_
on routemaste0_.route_id = routehalts0_.route_id
where routehalts0_.PLACE_ID = '51'
order by
routemaste0_.ROUTE_ID ASC )
I tried this way
SELECT rm.id ,
rm.routeCode ,
rm.startPlaceId ,
rm.endPlaceId ,
rm.active ,
rm.linkedRoute
FROM RouteMaster rm
INNER JOIN rm.routeHalts AS rh
WHERE rm.id = rh.routeId
AND rh.placeId = :PlaceId
ORDER BY rm.id ASC
but not getting the expected result. My concern is i need the inner join on condition to execute.
Can some one help me
I think that the reason of problem can be that route_id is not a primary key in any of tables. Thats why I recommend you to try Theta style join in this case:
And in your variant of HQL query you don’t need rm.id = rh.routeId part in where condition.