Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7943321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:14:21+00:00 2026-06-04T00:14:21+00:00

In ColdFusion using ORM, how do I to map a foreign key column referring

  • 0

In ColdFusion using ORM, how do I to map a foreign key column referring two tables?

My example.

At the moment an Image can belong to either a human or alien

Image.cfc
property name="imageID" fieldtype="id" generator="guid";

// Related Object Properties (many-to-one)
property name="Human" fieldtype="many-to-one" fkcolumn="HumanID" cfc="human";
property name="Alien" fieldtype="many-to-one" fkcolumn="AlienID" cfc="alien";

This leaves me with a table looking like this..

Image.cfc

    ID   NAME    HumanID  AlienID
    1    img1    10       NULL
    2    img2    NUll     8

To me NULLs smells bad!

So can I replace this with one mapping for both objects? Or If I create a category table? Any Ideas?

Thanks

Spark

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T00:14:24+00:00Added an answer on June 4, 2026 at 12:14 am

    You can’t map a single property to more than one parent object. So you have two options here.

    You will need to map this as a class per heirarchy where you will have classes for HumanImage and AlienImage that extend the base Image class

    // Image.cfc
    component persistent="true" {
        property name="id" generator="guid";
        property name="name";   
    }
    
    // AlienImage.cfc & HumanImage.cfc
    component persistent="true" extends="Image" joincolumn="id" {
    }
    
    // Alien.cfc
    component persistent="true"  {
        property name="id" generator="guid";
        property name="Image" fieldtype="one-to-many" cfc="AlienImage"
          fkcolumn="fkAlienID";
    }
    
    // Human.cfc
    component persistent="true"  {
        property name="id" generator="guid";
        property name="Image" fieldtype="one-to-many" cfc="HumanImage"
          fkcolumn="fkHumanID";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When using ColdFusion ORM where you have several tables with relationships can I bind
I'm using Coldfusion. I want to concatenate two strings into the same struct key,
I'm using Coldfusion ORM (Hibernate), and have a cfc mapped to a database table.
I've just begun learning about ColdFusion ORM and persistent cfcs and how it can
I'm using coldfusion to insert the contents of a struct (key-value pairs) into a
A question of ColdFusion ORM We are using ColdFusion 9 for the past 6
I'm using coldfusion to populate a google map - and I want different colored
We are using ColdFusion MX7. The CFDOCUMENT tag uses iText for the PDF creation
I'm using coldfusion 9 and I'm trying to grab a file from an ftp
I’m using Coldfusion MX 8. I recently had a situation where variables seem to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.