views:

52

answers:

1

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?

A: 

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)
Diego Mijelshon
Yes, You are right! Replaced the comma with JOIN Everything worked. I guess the syntax has changed since NHibernate 3
NHibernateNoobulator
Actually, the changed probably happened in NH 2.x
Diego Mijelshon