Is it possible to have an association between two domain classes (i.e. belongsTo
) if the other domain class uses a different datasource? The two datasources are different database drivers too.
I suspect this may not be possible, but I wanted to reach out to the community here to see if it was possible. Right now I'm trying to do it and I am getting the usual suspected Hibernate error:
Invocation of init method failed; nested exception is org.hibernate.MappingException: An association from the table domain_class_A refers to an unmapped class: DomainClassB
Sample:
class DomainClassA {
static belongsTo = [dcB: DomainClassB]
static mapping = {
datasource "ds1"
table name: "domain_class_A", schema: "schema_A"
}
}
class DomainClassB {
static hasMany = [dcA: DomainClassA]
static mapping = {
datasource "ds2"
table name: "domain_class_B", schema: "schema_B"
}
}