title: Grails multiple databases
body: <p>how can we write queries on 2 databases .</p>
  
  <p>I installed datasources plugin and domain classes are :</p>
  
  <pre><code>class Organization {
      long id
      long company_id
      String name
  
      static mapping = {
          version false
          table 'organization_'
          id column : 'organizationId'
          company_id column : 'companyId'
          name column : 'name'
      }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>class Assoc {
      Integer id
      Integer association_id
      Integer organization_id
  
  
      static mapping = {
          version false
          table 'assoc'
          id column : 'ASSOC_ID'
          association_id column : 'ASSOCIATION_ID'
          organization_id column : 'ORGANIZATION_ID'
      }
  }
  </code></pre>
  
  <p>this is working :<br/></p>
  
  <pre><code>def org = Organization.list()
  def assoc = Assoc.list()
  </code></pre>
  
  <p>and this is not working :<br/></p>
  
  <pre><code>def query = Organization.executeQuery("SELECT o.name as name, o.id FROM Organization o WHERE o.id IN (SELECT a.organization_id FROM Assoc a )")
  </code></pre>
  
  <p>error : </p>
  
  <blockquote>
    <p>org.hibernate.hql.ast.QuerySyntaxException: Assoc is not mapped
    [SELECT o.name as name, o.id FROM org.com.domain.Organization o WHERE
    o.id IN (SELECT a.organization_id FROM AssocOrg a )]</p>
  </blockquote>
  
  <p>How can we connect with 2 databases using single query ?</p>
  
  <p>thanks in advance .</p>