使用虚拟目录时 ColdFusion ORM 无法找到 CFC

发布于 2024-12-07 00:56:36 字数 1290 浏览 0 评论 0原文

我有一些具有关系的实体:

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";
}

上面的代码已简化。我的项目位于 C:\ColdFusion9\wwwroot\StoreTracker 中,一切运行良好。

但后来我不得不将其移动到虚拟目录。我将项目移至 C:\Projects\StoreTracker,但现在 ORM 不再工作,并出现以下错误:

无法加载 CFC 产品中关系属性存储的目标 CFC 存储。

找不到 ColdFusion 组件或界面 Store。

如果我通过使用以下方式完全限定名称:

property name="Store" fieldtype="many-to-one" cfc="entities.Store";

那么 ORM 就可以工作。有谁知道为什么将其移动到虚拟目录会导致 ORM 在错误的文件夹中搜索持久实体,并且是否有更简单的方法来更改它正在搜索的文件夹,这样我就不必完全限定每个关系?

编辑:

这是Application.cfc中的相关部分:

this.ormSettings = { cfclocation="entities" };

以及模型文件夹的文件夹结构:

C:\Projects\StoreTracker\entities

entities 文件夹下没有子文件夹,我的所有持久实体都在其中。

如果我将以下行添加到 Application.cfc 中,我就能让它正常工作:

this.mappings["/entities"] = "C:\Projects\StoreTracker\entities";

尽管我不确定为什么会这样。如果没有它,CF ORM 似乎可以很好地读取只有简单属性的实体,但是当存在关系时,它会爆炸说它找不到相关的 CFC。也许是一个错误?

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 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

红焚 2024-12-14 00:56:36

如果虚拟目录是指在 Apache 或 IIS 中设置的虚拟目录,那么这是有道理的。这些虚拟目录存在于 Web 服务器中,而不是 ColdFusion 中。 CF对它们一无所知。

您可能需要创建到您的应用程序的 ColdFusion 映射。我不确定您的应用程序的具体结构或放置 ORM 对象的位置,但您可能希望将类似的内容添加到伪构造函数区域中的 Application.cfc 中。

<cfset application.mappings["/StoreTracker"] = "C:\Projects\StoreTracker" />

更新:哦,别忘了 ormReload()

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()

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文