2
votes

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?

1
Do you have all your ORM CFCs in the one folder? Can you please post your ORM settings in Application.cfc please? - Ciaran Archer
yes, all the model cfcs are in the same folder. i assume it's because of the different datasource i use in the user model. - noobsaibot
Can you try move your table to the same datasource and see if that fixes it? - Ciaran Archer
works with the table in the same db. that sucks! providing the model with tablename, schema and catalog doesn't solve the problem either. - noobsaibot

1 Answers

2
votes

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