I have 2 tables, "company" and "user" with a many-to-many relation:
<cfcomponent entityname="company" persistent="true" table="company"
output="false">
<cfproperty name="user"
cfc="userGateway"
fieldtype="many-to-one"
fkcolumn="FK_user">
</cfcomponent>
<cfcomponent entityname="user" persistent="true" table="user" output="false">
<cfproperty name="companies"
cascade="all-delete-orphan"
fieldtype="one-to-many"
cfc="companyGateway"
fkcolumn="FK_user"
inverse="true"
singularname="company">
</cfcomponent>
(I only show the relevant code here)
When I want to retrieve a company based on the id of an associated user I do
this:
<cfquery name="local.company" dbtype="hql">
select c.id
from company as c
join user as u
where u.id=<cfqueryparam value="#arguments.userId#">
</cfquery>
I add the join syntax _without_ the columns to join on since that is defined in
the components using the cfproperty's fieldtype attribute.
An <cfdump var="#local.company#"><cfabort> gives me
Message Path expected for join! [ select c.id from company as c join user as u
where u.id=? ]
QueryString select c.id from company as c join user as u where u.id=?
Either my hql is wrong or something is wrong with the mappings but I can't
figure out what.. Does anyone have a clue?
Coldfusion 9,0,1,274733, Win7,MySQL 5.5.16
Marc
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:349879
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm