Interesting ColdFusion bug with ORM and relationships with other tables

So today I was writing a very quick and dirty maintenance program, and came across something that has stumped me for any sort of answer. Now there isn't anything special about the code and that is why it has me stumped.

There are two very simple table entities defined like so.

Page.cfc
component persistent="true" {
   property name="PageCode" ormtype="string" fieldtype="id" length="100";
   property name="CompanyCode" ormtype="string" length="10" fieldtype="id";
}
PageMapping.cfc
component persistent="true" {
   property name="PageMapping" ormtype="string" fieldtype="id";
   property name="CompanyCode" ormtype="string" length="10" fieldtype="id";
   property name="PageCode" fieldtype="one-to-many" CFC="Page" fkcolumn="PageCode,CompanyCode";
}

I have defined the ORM settings to drop and create the database, and have made sure that any tables have been totally deleted, just to make sure we are starting from a clean slate.

The error message that is displayed is as follows.

[Macromedia][SQLServer JDBC Driver][SQLServer]Column 'PageMapping.PageMapping' is not the same length or scale as referencing column 'Page.PageCode' in foreign key 'FKAB10EA50B6712144'. Columns participating in a foreign key relationship must be defined with the same length and scale.Other Errors :

  • [Macromedia][SQLServer JDBC Driver][SQLServer]Cannot find the object "Page" because it does not exist or you do not have permissions.
  • [Macromedia][SQLServer JDBC Driver][SQLServer]Cannot drop the table 'Expo', because it does not exist or you do not have permission.
  • [Macromedia][SQLServer JDBC Driver][SQLServer]Cannot drop the table 'ExpoContent', because it does not exist or you do not have permission.
  • [Macromedia][SQLServer JDBC Driver][SQLServer]Cannot drop the table 'ExpoType', because it does not exist or you do not have permission.
  • [Macromedia][SQLServer JDBC Driver][SQLServer]Cannot drop the table 'Page', because it does not exist or you do not have permission.
  • [Macromedia][SQLServer JDBC Driver][SQLServer]Cannot drop the table 'PageMapping', because it does not exist or you do not have permission.

The interesting thing to note here is that there are permission problems, and I am assuming that this is to do with the fact that the table hasn't been created correctly. The other thing to note is that the entities are being defined with composite keys, and that they have lengths defined to keep them to the size that I am after.

Now when we remove the tables from the database, and I remove the page primary key in page.cfc it all works fine. So going back to the documentation I didn't see anything about the keys and sizes of the columns, when being applied to the relationship.

Not sure on how to overcome this, but it is interesting and something that one will need to perhaps take into consideration.


Interesting ColdFusion bug with ORM and relationships with other tables - http://goo.gl/ickdo Aug 4, 2011
Interesting ColdFusion bug with ORM and relationships with other tables http://fb.me/tG5pDAiH Aug 4, 2011