【问题标题】:Lucee ORM there is no Session for the datasourceLucee ORM 数据源没有 Session
【发布时间】:2016-05-10 21:46:25
【问题描述】:

我正在尝试在 Lucee 服务器中使用 ORM,但继续收到错误 there is no Session for the datasource [mydatasource]。数据源确实存在并且连接正常,在管理员中验证并使用 cfquery 进行了测试。

这里是application.cfc

<cfcomponent>

<cffunction name="onRequestStart" access="public" returntype="boolean" output="false">
    <cfset this.datasource = "rift" />
    <cfset this.ormEnabled = true />
    <cfsetting showdebugoutput="false" />
    <cfset this.ormsettings = { } />
    <!---<cfset this.ormsettings.dbcreate = "dropcreate" />--->
    <cfset this.ormsettings.logSQL = true />
    <cfset ORMReload() />
    <cfset testquery = ORMExecuteQuery("from test")>
    <cfreturn true />
</cffunction>

</cfcomponent>

【问题讨论】:

  • 嗯...如果启用会话管理会发生什么?

标签: orm coldfusion lucee


【解决方案1】:

ORMSettings 应该在伪构造函数中定义,所以我相信这就是导致问题的原因。

<cfcomponent output="false">

    <!--- define orm settings --->
    <cfset this.datasource = "rift" />
    <cfset this.ormEnabled = true />
    <cfset this.ormsettings.logSQL = true />


    <cffunction name="onRequestStart" access="public" returntype="boolean" output="false">
        <cfif StructKeyExists(url, "reload")>
            <!--- you don't want to do this on every request --->
            <cfset ORMReload() />
        </cfif>
        <cfset testquery = ORMExecuteQuery("from test")>
        <cfreturn true />
    </cffunction>

</cfcomponent>

还要确保您已将您的 cfc 命名为 test.cfc,并且它已设置为持久化。

【讨论】:

  • 哈哈,都没注意到!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-06-06
  • 2022-12-04
  • 2015-02-08
相关资源
最近更新 更多