ColdFusion: ORM collection with multiple foreign keys

My database structure basically consists of several primary keys for each table, so multiple columns are required for each connection. I am trying to use the ColdFusion (11 to be specific) property of the ORM collection . It seems that the column list in the fkColumn attribute fkColumn not separated by commas, as is the case for properties. I filed an error with Adobe , but I wonder if someone else came across this and found workarounds. Or maybe I'm just doing it wrong.

Table setting

 Years Staff StaffSites Sites =========== ============ ============ =========== YearID (PK) StaffID (PK) YearID (PK) SiteID (PK) YearName StaffName StaffID (PK) SiteName SiteID (PK) 

ORM CFC Staff

 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'; } 

Problem

An error occurs when starting the generated query: [Macromedia][SQLServer JDBC Driver][SQLServer]An expression of non-boolean type specified in a context where a condition is expected, near ','.

Looking at the generated query, it seems that the list of columns is not parsed correctly for the where clause, but he understands somewhat that there are several 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=? 

goal

For an ORM collection property to properly support merging with multiple keys. Why not use a relationship? I would like to use ORM objects to then serialize as JSON for use in REST services. Serialized JSON should contain the identifier for the relationship, 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"}, ] } 
+6
source share
1 answer

For your database structure, the easiest way to translate to ORM is to use "StaffSites" as a linktable for many-to-many relationships.

You should try CF11 Custom serializer http://blogs.coldfusion.com/post.cfm/language-enhancements-in-coldfusion-splendor-improved-json-serialization-2

0
source

Source: https://habr.com/ru/post/984567/


All Articles