如何为多个会话范围 DSN 配置 ColdFusion 的 ORM?
如果可能的话,如何配置 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
随着 ColdFusion 9.0.1 更新引入,您可以使用多个数据源使用 ORM。每个组件一次一个。在对象中使用“datasource”属性来指定应使用哪个数据库。
或者
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.
or
尽管可以将 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.