如何为多个会话范围 DSN 配置 ColdFusion 的 ORM?

发布于 2024-12-16 20:11:06 字数 1363 浏览 3 评论 0原文

如果可能的话,如何配置 ColdFusion 9 的 ORM 以使用多个 DSN?

是否可以在会话范围而不是应用程序范围的上下文中设置数据源?

或者,在 CF9 中,如何配置 Hibernate 以使用多个 DSN?


看来我应该更具体一点... 我正在寻找一种允许根据会话指定 DSN 的解决方案。

这是场景。我们有一个自定义构建的应用程序,它使用从子域确定的多个 DSN。因此,从 http://abc.domain.com 访问的人将使用 abc DSN,就像访问 xyz 的人一样。 domain.com 将使用 xyz DSN。 DSN 的名称在创建会话时确定,并存储为会话变量。

我想做这样的事情:

//Artists.cfc

component persistent="true" datasource="#session.dsn#"
{ 
property name="artistid" generator="increment"; 
property firstname; 
property lastname; 
property address; 
property city; 
property state; 
}

// Application.cfc

component output="false" { 
THIS.name = "MultipleDsnORMTest"; 
THIS.applicationTimeout = createTimeSpan(0, 0, 0, 0); 
THIS.clientManagement = false; 
THIS.datasource = ""; // Leaving black ==> "No data source specified."
                      // Setting to cfbookclub ==> "ORM is not 
                      //   configured for the current application."
                      // Setting to cfartgallery works but doesn't 
                      //   demonstrate use multiple DSNs
THIS.loginStorage = "cookie"; 
THIS.sessionManagement = true; 
THIS.sessionTimeout = createTimeSpan(0, 0, 0, 0); 

THIS.ormenabled = true; 
THIS.ormsettings = {}; 
}

How do you configure ColdFusion 9's ORM to use multiple DSNs if possible?

Is is possible to setup the datasource in the context of a session scope instead of the application scope?

Or how, in CF9, do you configure Hibernate to use multiple DSNs?


Looks like I should be more specific...
I'm looking for a solution that allows for specifying a DSN based on the session.

Here's the scenario. We have a single custom built application that uses multiple DSNs which are determined from the sub-domain. So someone accessing from http://abc.domain.com would use the abc DSN where as someone visiting the xyz.domain.com would use the xyz DSN. The name of the DSN is determined when the session is created and it is stored as a session variable.

I'd like to do something like this:

//Artists.cfc

component persistent="true" datasource="#session.dsn#"
{ 
property name="artistid" generator="increment"; 
property firstname; 
property lastname; 
property address; 
property city; 
property state; 
}

// Application.cfc

component output="false" { 
THIS.name = "MultipleDsnORMTest"; 
THIS.applicationTimeout = createTimeSpan(0, 0, 0, 0); 
THIS.clientManagement = false; 
THIS.datasource = ""; // Leaving black ==> "No data source specified."
                      // Setting to cfbookclub ==> "ORM is not 
                      //   configured for the current application."
                      // Setting to cfartgallery works but doesn't 
                      //   demonstrate use multiple DSNs
THIS.loginStorage = "cookie"; 
THIS.sessionManagement = true; 
THIS.sessionTimeout = createTimeSpan(0, 0, 0, 0); 

THIS.ormenabled = true; 
THIS.ormsettings = {}; 
}

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

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

发布评论

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

评论(2

娜些时光,永不杰束 2024-12-23 20:11:06

随着 ColdFusion 9.0.1 更新引入,您可以使用多个数据源使用 ORM。每个组件一次一个。在对象中使用“datasource”属性来指定应使用哪个数据库。

<cfcomponent displayname="firstObject" datasource="dbOne">
    <cffunction>
        ...
    </cffunction>

    ...
</cfcomponent>

或者

component datasource = 'dbOne'{
    ...
}

Introduced with the ColdFusion 9.0.1 update, you can use multiple data sources with ORM. One at a time per component. Use the "datasource" attribute in your object, to specify which database should be used.

<cfcomponent displayname="firstObject" datasource="dbOne">
    <cffunction>
        ...
    </cffunction>

    ...
</cfcomponent>

or

component datasource = 'dbOne'{
    ...
}
浮生面具三千个 2024-12-23 20:11:06

尽管可以将 ColdFusion 9 配置为在应用程序范围内使用具有 ORM 的多个数据源,但无法将 ColdFusion 9 的 ORM 配置为在会话范围内使用多个 DSN。

Although it is possible to configure ColdFusion 9 to use multiple data sources with ORM in the application scope, it is not possible to configure ColdFusion 9's ORM to work with multiple DSNs within the session scope.

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