Joh*_*n N 5 coldfusion orm application.cfc coldfusion-9
我有CF9 ORM映射的问题.
我不时会收到以下错误(是的,大部分时间都可以正常工作),
Mapping for component model.Pubs not found. Either the mapping for this component is missing or the application must be restarted to generate the mapping.
Run Code Online (Sandbox Code Playgroud)
Application.cfc中的ORM定义
<cfscript>
this.datasource = "Pubs";
this.ormenabled = true;
this.ormsettings= {
dialect="MicrosoftSQLServer",
dbcreate="update",
eventhandling="true"
};
</cfscript>
<cfset this.mappings["/model"] = getDirectoryFromPath(getCurrentTemplatePath()) & "model" />
Run Code Online (Sandbox Code Playgroud)
修复它的唯一方法是刷新ORM几次,这是通过在Application.cfc上命中?init = true.它仍然是一个临时解决方案,但我需要知道它的根本原因并修复它.
<cfscript>
if(structKeyExists(url, "init")) { ormReload(); applicationStop(); location('index.cfm?reloaded=true'); }
Run Code Online (Sandbox Code Playgroud)
请指教.
谢谢!
好的,谢谢@Henry 和@Walter 的评论。他们是找到正确解决方案的带头人。
这就是我为确保它始终稳定而所做的事情。
在/root/Application.cfc上,我调整了以下代码
<cfset application.mappings["/ormmodel"] = expandPath("/root/ormmodel") />
Run Code Online (Sandbox Code Playgroud)
和
this.ormsettings= {
cfclocation = ["ormmodel"],
autogenmap = true,
...
eventhandling="true"
};
Run Code Online (Sandbox Code Playgroud)
请注意 cfclocation 值中缺少“/”。
在调用模型组件时,我将代码从 pub = new ormmodel.Pubs() 更改为
pub = EntityNew("Pubs");
Run Code Online (Sandbox Code Playgroud)在一个不相关的点上,我已将组件名称更改为驼峰式命名,并避免使用下划线和破折号等特殊字符。
我希望这会有所帮助,并为其他人节省数小时的沮丧和悬念。
快乐编码!
| 归档时间: |
|
| 查看次数: |
1568 次 |
| 最近记录: |