tracker issue : CF-3963346

select a category, or use search below
(searches all categories and all time range)

ORM Collection Mapping Multiple Foreign Keys

| View in Tracker

Status/Resolution/Reason: To Fix//

Reporter/Name(from Bugbase): Ryan Panning / Ryan Panning (Ryan Panning)

Created: 04/01/2015

Components: ORM Support

Versions: 11.0

Failure Type: Enhancement Request

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Trivial / Unknown

Locale/System: English / Win 2008 Server R2 64 bit

Vote Count: 0

Problem Description: For an ORM component, a 'collection' property does not support a comma delimited list of multiple foreign keys, the 'fkcolumn' attribute. The same *does* work for relationships (as stated in the documentation). It seems like ColdFusion doesn't properly parse the columns for the WHERE clause, but it somewhat knows there are multiple columns in the SELECT expression. My database mainly has two keys per join, as records are separated per year.

Steps to Reproduce:
Two database tables;
FooID (PK)
YearID (PK)

BarID (PK)
FooID (FK)
YearID (FK)

/** foo.cfc **/
component persistent=true table='Foos' {
    property name='id' column='FooID' fieldType='id' type='numeric' setter=false;
    property name='year' column='YearID' fieldType='id' type='numeric' setter=false;
    property name='bars' elementColumn='BarID' table='Bars' fkColumn='FooID,YearID' fieldType='collection';

Actual Result: [Macromedia][SQLServer JDBC Driver][SQLServer]An expression of non-boolean type specified in a context where a condition is expected, near ','.

ORM Generated Query:
2015-04-01 09:14:47,844 [ajp-bio-8014-exec-357] Hibernate DEBUG org.hibernate.SQL - 
    YearID as FooID1_2_0_,
    bars0_.BarID as BarID4_0_ 
    Bars bars0_ 

Expected Result: No exceptions. ColdFusion should properly parse the multi-column list of keys.

Any Workarounds: None that I've found.

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3963346

Reason:	NewBug

External Customer Info:
External Company:  
External Customer Name: Ryan
External Customer Email:  
External Test Config: My Hardware and Environment details: Win 2008 Server R2 64 bit, IIS Connector to ColdFusion, Microsoft SQL database server



FYI, I've posted a StackOverflow question that details my usage more specifically.
Comment by External U.
7959 | April 01, 2015 10:02:04 AM GMT
Oh, and to clarify, the generated query should be something like this: select bars0_.BarID from Bars bars0_ where bars0_.FooID=? and bars0_.YearID=?
Comment by External U.
7960 | April 02, 2015 10:17:20 AM GMT