ColdFusion ORM cannot find CFCs when using virtual directory
I have some entities with relationships:
component name="Store" persistent="true"
{
property name="Products" fieldtype="one-to-many" cfc="Product";
}
component name="Product" persistent="true"
{
property name="Store" fieldtype="many-to-one" cfc="Store";
}
The above code is simplified. My project resided in C:\ColdFusion9\wwwroot\StoreTracker
, and everything worked great.
But then I had to move it to a virtual directory. I moved my project to C:\Projects\StoreTracker
, but now the ORM does not work anymore with the following error:
Cannot load the target CFC Store for the relation property Store in CFC Product.
Could not find the ColdFusion component or interface Store.
If I fully qualify the name though by using:
property开发者_JAVA百科 name="Store" fieldtype="many-to-one" cfc="entities.Store";
then the ORM works. Does anybody know why moving it to a virtual directory causes the ORM to search through the wrong folder for persistent entities, and if there's an easier way to change which folder it's searching through so I don't have to fully qualify every relationship?
Edit:
Here is the relevant part in Application.cfc
:
this.ormSettings = { cfclocation="entities" };
And the folder structure for the model folder:
C:\Projects\StoreTracker\entities
There are no sub-folders under the entities folder and all my persistent entities are in there.
I was able to get it to work correctly if I add the following line to Application.cfc
:
this.mappings["/entities"] = "C:\Projects\StoreTracker\entities";
Though I'm not sure why this works. Without it, CF ORM seems to read the entities just fine if they only have simple properties, but when there's a relationship, it bombs out saying that it can't find the related CFC. Perhaps a bug?
If by virtual directory you mean a virtual directory set up in Apache or IIS, then this makes sense. Those virtual directories exist in the web server, not in ColdFusion. CF has no knowledge of them.
You probably need to create a ColdFusion mapping to your application. I am not sure exactly how your app is structured or where you are putting your ORM objects, but you may want to add something like this to your Application.cfc in the pseudo-constructor area.
<cfset application.mappings["/StoreTracker"] = "C:\Projects\StoreTracker" />
Update: Oh and don't forget to ormReload()
精彩评论