My database structure mainly consists of multiple primary keys per table, therefore multiple columns are required per join. I'm trying to use ColdFusion (11 to be specific) ORM collection property. It seems that a comma separated list of columns in the fkColumn
attribute doesn't work, like it does for relationship properties. I have filed a bug with Adobe, but I'm wondering if anyone else has run into this and found workarounds. Or maybe I'm just doing it wrong..
Table Setup
Years Staff StaffSites Sites
=========== ============ ============ ===========
YearID (PK) StaffID (PK) YearID (PK) SiteID (PK)
YearName StaffName StaffID (PK) SiteName
SiteID (PK)
Staff ORM CFC
component persistent=true table='Staff' {
property name='id' column='StaffID' fieldType='id';
property name='year' column='YearID' fieldType='id';
property name='sites' elementColumn='SiteID' fieldType='collection' table='StaffSites' fkColumn='StaffID,YearID';
}
The Problem
There is an error when running the generated query: [Macromedia][SQLServer JDBC Driver][SQLServer]An expression of non-boolean type specified in a context where a condition is expected, near ','.
Taking a look at the generated query, it appears that the list of columns is not properly parsed for the where
clause, but it somewhat understands that there are multiple columns in the select
expression.
select
sites0_.StaffID,
YearID as StaffID1_2_0_,
sites0_.SiteID as SiteID4_0_
from
StaffSites sites0_
where
sites0_.StaffID,YearID=?
The Goal
For the ORM collection property to correctly support a multi-key "join". Why not use a relationship? I'd like to use ORM objects to then serialize as JSON for use in the REST services. The serialized JSON needs to contain the ID for the relationships, not the actual relationship data. For example, the JSON payload should be:
{
"id": 1234,
"year": 2015,
"sites": [1,2,3]
}
Instead of something like:
{
"id": 1234,
"year": 2015,
"sites": [
{"id": 1, "name": "Foo"},
{"id": 2, "name": "Bar"},
{"id": 3, "name": "Baz"},
]
}