Question

Yesterday, I upgraded my NHibernate application from 1.2 to 3.0. I get the following exception

c.SubContractors is not mapped [SELECT count(distinct c) FROM CallUp c, c.SubContractors sc Where sc.id = :id AND c.ChildCallUp IS NULL AND c.State > 0 AND (:start_date BETWEEN c.ContractStartDate AND c.ContractEndDate OR :end_date BETWEEN c.ContractStartDate AND c.ContractEndDate)]

I can't seem to fix this problem... any suggestion?

Was it helpful?

Solution

The HQL syntax is incorrect. Use:

SELECT count(distinct c) 
FROM CallUp c JOIN c.SubContractors sc 
WHERE sc.id = :id 
AND c.ChildCallUp IS NULL 
AND c.State > 0 
AND (:start_date BETWEEN c.ContractStartDate AND c.ContractEndDate 
     OR :end_date BETWEEN c.ContractStartDate AND c.ContractEndDate)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top