I have a formula imbedded in my hbm file as follows:
Code:
<class
name="HighEnergy.Domain.ContactImpl, HighEnergyCore"
table="CONTACT"
dynamic-insert="false"
dynamic-update="false"
>
...
<property name="CountSelfCompanies" type="Int64" formula="(select count(*) from company_contact cc, company c where cc.company_fk=c.id and cc.role=0 and c.type=0 and cc.contact_fk=id)" />
</class>
NHibernate seems to generate incorrect SQL when it tries to fetch this entity:
Code:
SELECT
...
(select
count(*)
from
company_contact cc,
contacti1_.company contacti1_.c <---- This is the line where I get a syntax error
where
cc.company_fk=c.id and
cc.role=0 and
c.type=0 and
cc.contact_fk=contacti1_.id) as f1_0_
FROM
TRADE_CONTACT contacts0_
left outer join CONTACT contacti1_ on contacts0_.CONTACT_FK=contacti1_.ID
WHERE
contacts0_.TRADE_FK = 201
ORDER BY contacts0_.TRADE_FK
This is the error I am getting:
Code:
Incorrect syntax near '.'
Why does NHibernate change "company c" to "contacti1_.company contacti1_.c"? Am I doing something wrong?