1 Reply Latest reply on Oct 7, 2010 1:10 AM by Jesus Vega

    Doubt on Join Mapping documentation

    Jesus Vega

      Dear all,


      Let me present the following case: I'm working against an Oracle database where I have two tables ASSET (id NUMBER, name VARCHAR2, asset_type_id NUMBER) and ASSET_TYPE (id NUMBER, type_name VARCHAR2).


      What I want to try is to build an Asset.cfc with the id (numeric), name (string), and typeName (string) properties. I tried to avoid having an AssetType class loaded into the type property that later I had to access with asset.getType().getTypeName(), but having the typeName string directly as asset.getTypeName().


      Then I read the "Join mapping in a CFC" section of the CF9 documentation and thought to have found an elegant solution. The document presents the Employee-Address relationship and uses the addressId joincolumn, but never explains if the addressId column is member of the Employee or the Address table. I guessed the addressId was a column of the Employee table pointing to the PK of the Address table, and tried to apply that logic to my case; of course, it does not work. Then I reached the conclusion that the addressId must be a member of Address table that maps automatically always to the PK of the Employee table.


      (1) Is my conclusion right? I.e. is the joincolumn a member of the target table and joins always automatically to the defined PK of the source table? If this is the case, I cannot solve my problem this way as I want to join the target id column with the source asset_type_id column.


      (2) Is there a way to override this and make the joincolumn to join to an alternative source column other than the PK?


      (3) Does anyone knows the why of this limitation?


      (4) Could anyone explain an alternative way for getting the type string directly with asset.getType() without creating an explicit AssetType cfc? Is there some pattern or best practice for this case?


      Sorry for the long post and thanks in advance for your help.