0

Working with the datasources plugin using grails 1.3.6 (will upgrade soon) I get this error when rendering a taglib

org.springframework.orm.hibernate3.HibernateQueryException: DomainA is not mapped

These are the databases (both are postgresql and are located in the same server):

database A
    schema x
        table domain_a
        table domain_b
database B
    schema x
        table DomainA
        table DomainB

These are my mappings:

class domainA { // Domain A is defined in a plugin
    mapping(table: "x.domain_a")
}

class domainB {
    mapping(table: "x.domain_b")
}

What I want is domainA to be mapped in Database A and domainB to be mapped in Database B.

I'm using grails.config.locations in Config.groovy for Database A and Datasources.groovy for Database B with this config:

datasource(name: 'databaseB') {
    driverClassName('org.postgresql.Driver')
    url('jdbc:postgresql://host/databaseB')
    username('user')
    password('****')
    domainClasses(['DomainB'])
    readOnly(true)
    dialect("org.hibernate.dialect.PostgreSQLDialect")
    pooled(true)
    environments(['development', 'test'])
}

I don't get what seems to be the problem

Has anyone had this trouble, Is there a workaround I could use? Maybe an upgrade to grails 2 could help?

nardhar
  • 15
  • 1
  • 3
  • Try domainClasses([DomainA]) and domainClasses([DomainB]) and import class in the file instead of using string. – practical programmer Jan 19 '13 at 18:06
  • I've already done that, in fact string is the other attempt i tried. Before it was like this: domainClasses([package.DomainB]) – nardhar Jan 19 '13 at 23:57
  • I use multiple datasources in Grails 2.x with no problems, but I don't need to use plugin + external configuration for that. You should check http://stackoverflow.com/questions/970133/externalizing-grails-datasource-configuration . External datasource configuration requires a trick – practical programmer Jan 20 '13 at 00:48
  • Guess I'll try Grails 2 after all, guess it's something with the main datasource's configuration and its domains. – nardhar Jan 21 '13 at 12:45

1 Answers1

0

Well, I kinda solved creating another datasource with database A (the main one) in datasources.groovy and including domainA (and all other domains related) in there, like this:

import package.DomainA

datasource(name: 'databaseA') {
    driverClassName('org.postgresql.Driver')
    url('jdbc:postgresql://host/databaseA')
    username('user')
    password('***')
    domainClasses([DomainA, OtherDomains])
}
nardhar
  • 15
  • 1
  • 3