title: How to configure ColdFusion's ORM for multiple session scope DSNs?
body: <p>How do you configure ColdFusion 9's ORM to use multiple DSNs if possible?</p>
  
  <p>Is is possible to setup the datasource in the context of a session scope instead of the application scope?</p>
  
  <p>Or how, in CF9, do you configure Hibernate to use multiple DSNs?</p>
  
  <hr>
  
  <p>Looks like I should be more specific...
  I'm looking for a solution that allows for specifying a DSN based on the session.</p>
  
  <p>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 <a href="http://abc.domain.com" rel="nofollow">http://abc.domain.com</a> 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.  </p>
  
  <p>I'd like to do something like this:</p>
  
  <p>//Artists.cfc</p>
  
  <pre><code>component persistent="true" datasource="#session.dsn#"
  { 
  property name="artistid" generator="increment"; 
  property firstname; 
  property lastname; 
  property address; 
  property city; 
  property state; 
  }
  </code></pre>
  
  <p>// Application.cfc</p>
  
  <pre><code>component output="false" { 
  THIS.name = "MultipleDsnORMTest"; 
  THIS.applicationTimeout = createTimeSpan(0, 0, 0, 0); 
  THIS.clientManagement = false; 
  THIS.datasource = ""; // Leaving black ==&gt; "No data source specified."
                        // Setting to cfbookclub ==&gt; "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 = {}; 
  }
  </code></pre>