I am trying to add relationships to a component (entity) in Coldbox, in particular many-to-many and one-to-many, and getting one of the following errors:
An association from the refers to an unmapped class (many-to-many relationship mapping)
Association references unmapped class (one-to-many relationship mapping)
After I added the relationship and perform an ormReload, I see one of the above errors. If I comment out the relationship and do an ormReload, everything is fine.
ORM entity properties and relationships have nothing to do with ColdBox. The only thing ColdBox does if you use Wirebox to inbect anything into the Entity.
Maybe giving us an example of what your trying to do. But normally with an error message like that you either have the Entity name wrong or you have the table name wrong.
An association from the clients_services refers to an unmapped class:
(for the many-to-many relationship mapping)
Association references unmapped class:
(for a one-to-many relationship mapping)
If you need the stack trace, I will need to recreate and supply them tomorrow. But it didn’t shed anymore light for me.
If I place the model under /modules/solitary/model, then there are no issues with the relationship mapping . However if i place at the application root level, i.e. /model/, it fails.
Seems like it is not picking up the model at the application root level for orm relationship mappings. But if i commented out the relationship part of the model, it does successfully created the tables for models in the application level, i.e.models in \model.
So is the following correct (in particular the cfclocation parameter) for ormSettings in application.cfc:
Ok I am asking because if you change the Entity location then the CFC property needs to be adjusted to that location and I assume Solitary as a mapping defined in the Application.cfc
Also may pay to read the ColdFusion documentation when it comes to Entity relationships.
If the same model cfc works under \modules\solitary\model, and not under \model, then I think the error is not in the mapping definition.
That is, if I now move all the associated model cfc to \model, and do an ormReload, it will fail; however if I move them back to \modules\solitary\model, it will succeed.
But when you move them what are you putting in the CFC attribute on the property, again this is very basic ORM relationship stuff. I suggest reading the ColdFusion docs on those Entity properties.
It is fixed now!!
Solution:
The path to the cfc parameter in the relationship definition must be absolute from the webroot, i.e. cfc=“full.path.from.webroot.model.services.Service”.