I've come across a peculiarity in GORM mapping.
What I expect table-wise is
models
designs (model_id -> models.id)
categories
categories_design (category_id, design_id)
To get a model_id in designs, I would use map syntax
static belongsTo = [model:Model]
So now, I also have a hasMany relationship between Design and Category and the owning side is Design.
The GORM manual says to denote an owning side using non-map syntax
static belongsTo = Category
BUT, I also need the back reference from Design to Model that uses map notation.
My question is how do you mix the 2 cases?
I have tried, in Design:
static belongsTo = [model:Model, category:Category]
This gets a runtime error - No owner defined between domain classes Category and Design in many-to-many relationship.
static belongsTo = [model:Model, Category]
This gives a compile error.
static belongsTo = [Model, Category]
The expected model_id is not created in Design, instead a whole new table for models_designs is created which is not right. But everything compiles and runs.