How to configure ColdFusion ORM for multi-session DSN?

How to configure ColdFusion 9 ORM to use multiple DSNs, if possible?

Is it possible to set the data source in the context of the session area instead of the application area?

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


It seems like I should be more specific ... I'm looking for a solution that allows you to specify a DSN based on a session.

Here is the script. We have one custom application that uses several DSNs that are defined from a subdomain. That way, someone accessing from http://abc.domain.com will use abc DSN, where, when someone visits xyz.domain.com, they will use xyz DSN. The DSN is defined when the session is created and saved as a session variable.

I would 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 = {}; } 
+6
source share
2 answers

Although you can use multiple data sources with ORM in the application area in ColdFusion 9, you cannot configure ColdFusion 9 ORM to work with multiple DSNs within a session.

+1
source

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

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

or

 component datasource = 'dbOne'{ ... } 
+1
source

Source: https://habr.com/ru/post/901785/


All Articles