0

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 relation property that has a linktable. I think the issue is with two keys on one side of the many-to-many relationship and just one on the other. Here is what I've tried without success:

Table Setup

Staff            StaffSites       Sites
============     ============     ===========
YearID (PK)  --- YearID (PK)
StaffID (PK) --- StaffID (PK)     SiteName
StaffName        SiteID (PK)  --- 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='name' column='StaffName';

    property name='sites'
        cfc='site'
        linkTable='StaffSites'
        fkColumn='YearID,StaffID'
        inverseJoinColumn='SiteID'
        mappedBy='id'
        fieldType='many-to-many'
        lazy=true;
}

Site ORM CFC

component persistent=true table='Sites' {
    property name='id'   column='SiteID' fieldType='id';
    property name='name' column='SiteName';
}

ColdFusion Error

collection foreign key mapping has wrong number of columns: staff.sites type: integer
Panman
  • 1,157
  • 2
  • 8
  • 19

1 Answers1

0

If the join table has multiple foreign key columns (that reference the composite key of the target table), then you must use comma-separated column names.Also, the order in which the column names are specified must match the order of composite keys defined.

http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WS5FFD2854-7F18-43ea-B383-161E007CE0D1.html

Composite key should be supported.

Try switching the id's since you define staff id first, and also specify the orm type on the id's just in case. Also, try swapping inverseJoinColumn with fkColumn, I never remember which should be which but that'd be something I'd try.

Henry
  • 32,689
  • 19
  • 120
  • 221