Hello,
Hibernate 3.0.3
Oracle 9i
I used the following native sql query and i got the expected results.
Code:
SELECT obj.objective_uid, obj.name
FROM Objective obj INNER JOIN
(SELECT DISTINCT orbt.objective_uid as temp_obj_uid FROM Objective_Result_Bt orbt INNER JOIN Result_Bt rbt
ON orbt.result_bt_uid = rbt.result_bt_uid WHERE rbt.lgrain_mmperiod_type_uid <= 3) TEMP
ON obj.objective_uid = temp.temp_obj_uid
WHERE obj.objective_type = 4
***
a)objective_uid in OBJECTIVE_RESULT_BT table represents a foreign key(MANY-TO-ONE from OBJECTIVE_RESULT_BT to OBJECTIVE) for objective_uid primary key column in OBJECTIVE table in database
b)result_bt_uid in OBJECTIVE_RESULT_BT table represents a foreign key(MANY-TO-ONE from OBJECTIVE_RESULT_BT to RESULT_BT) for Result_Bt_Uid primary key column in Result_Bt table in database
But when i converted the above SQL query to HQL query as mentioned below :
Code:
select objective.pmcID, objective.name
from Objective objective inner join
( select distinct orbt.objective.pmcId as temp_objective_id
from ObjectiveResultBt orbt inner join ResultBt rbt on orbt.resultBt.pmcId = rbt.pmcId
where rbt.metricMeasurementPeriodType.measurementTypeID <= :lgm_Id
) temp
on objective.pmcId = temp.temp_objective_id
where objective.objectiveType.type = 4
I got the following error :
Unxpected token : ( line 4, column 1What i am guessing is that because temp is not at all related to any entity(as it doesn't exist) this error may be coming.Am i correct??
If yes then how can i make use of the concept i used in the native SQL query to get the desired results, in HQL??
Regarding the same problem i tried another HQL query as mentioned below:
Code:
select objective.pmcID, objective.name
from Objective objective where objective.objectiveType.type = 4 and objective.pmcID in
( select distinct orbt.objective.pmcId
from ObjectiveResultBt orbt inner join ResultBt rbt on orbt.resultBt.pmcId = rbt.pmcId
where rbt.metricMeasurementPeriodType.measurementTypeID <= :lgm_Id
)
When executed the above query i got the error : "Path expected for join!" .
What does this error indicate and how to resolve the same????
Please comment on the above mentioned queries..
Thanks