Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.3 RC2
-
Fix Version/s: 2.3-M2
-
Component/s: Persistence
-
Labels:None
Description
I have three domain objects in my model, ThesisDocument extending SimpleDocument, which in turn extends Document.
The objects in my domain model come from two schemas, "document_schema" and "user_schema". In the data source configuration I provide the URL that refers to one of the schemas (document_schema).
The code for the objects uses explicit schema reference:
static mapping = { table name:"thesis_document", schema_name:"document_schema" }
When I query ThesisDocument (using list()), GORM generates the following SQL:
select
this_.id as id28_0_,
this_2_.version as version28_0_,
...
from
thesis_document this_
inner join
simple_document this_1_
on this_.id=this_1_.id
inner join
document_schema.document this_2_
on this_.id=this_2_.id limit ?
Note that only "document" table has a fully qualified reference (document_schema.document). The other two tables (thesis_document and simple_document) are referred to using unqualified names.
Thus, if I point to "user_schema" in DataSource.groovy (there are problems related to many-to-many join tables requiring me to do that), the query fails (looking for user_schema.thesis_document).
A workaround I found is instead of
static mapping = { table name:"thesis_document", schema_name:"document_schema" }
to use
static mapping = { table name:"document_schema.thesis_document" }
This works, but it is a hack. The query should use fully qualified table names for all table involved.
Could you post more of the domain class mapping?