Grails multiple databases

Posted by srinath on Stack Overflow See other posts from Stack Overflow or by srinath
Published on 2010-03-08T10:04:12Z Indexed on 2010/03/08 10:06 UTC
Read the original article Hit count: 485

Filed under:
|

Hi,

how can we write queries on 2 databases .

I installed datasources plugin and domain classes are :

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'
}

}


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'
}

}

this is working :
def org = Organization.list()
def assoc = Assoc.list()

and this is not working :

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 )")

error :

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 )]

How can we connect with 2 databases using single query ?

thanks in advance .

© Stack Overflow or respective owner

Related posts about grails

Related posts about multiple