Question

i have to model classes User and Order. what i want is to have a relationship between them, so that a user has many orders, which in this case would be a one-to-many rel. which i defined in the User.cfc as follows:

property name="orders"
         fieldtype="one-to-many"
         cfc="Order"
         fkcolumn="userID"
         type="array";

each of this cfcs can be loaded through EntityLoad( Entity Name ) without any problems; i see all the data in the dump output.

however, as soon as i put the orders relationship in the User.cfc, it all breaks apart and i get an error message:

Association references unmapped class: Order

here's the code for the cfcs

User.cfc

component persistent="true" datasource="otherDatasource"
{
    property    name="id" fieldtype="id";
    property    name="userName";
    property    name="password";
    property    name="firstName";
    property    name="lastName";
    property    name="title";
    property    name="orders"
                fieldtype="one-to-many"
                cfc="Order"
                fkcolumn="userID"
                type="array";

    function init()
    {
        return this;
    }
}

Order.cfc

component persistent="true"
{
    property name="id" fieldtype="id" generator="guid";
    property name="quantity";
    property name="period";
    property name="region";
    property name="createdAt" ormtype="date";

    function init()
    {
        return this;
    }
}

Any ideas what i'm doing wrong here?

Was it helpful?

Solution

it seems as i have my answer. coldfusion 9.0.1 orm isn't capable of building a relationship between tables in different databases.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top