我有一个与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.
在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" />
唯一的解决方法是多次刷新ORM,通过在Application.cfc上加上?init=true来实现。这仍然是一个临时解决方案,但我需要知道它的根本原因并加以修复。
<cfscript>
if(structKeyExists(url, "init")) { ormReload(); applicationStop(); location('index.cfm?reloaded=true'); }
请给予建议。
谢谢!
ormsettings
中设置cfclocation
,这样你就不需要在初始化中使用applicationStop
。 - Henry