ORM RDBS.
So, you have three tables: organization, charity, company. The user belongs only to the Organization (not Charity or Company). How are you going to get the value of certain fields? There is a USER. We know the ORGANIZATION, but we don’t know the Charity or Company. I think you understand ...
I can offer you three solutions:
1. tablePerHierarchy true (But you need to have fields with null values \ Company fields)
2.
class User {
static belongsTo = [charity: Charity, company: Company]
}
class Charity {
String name
static hasMany = [users: User]
}
class Company {
String name
static hasMany = [users: User]
}
3.
class User {
static belongsTo = [organization: Organization]
}
class Organization {
String name
Charity charity
Company company
static hasMany = [users: User]
}
class Charity {
static belongsTo = [organization: Organization]
}
class Company {
static belongsTo = [organization: Organization]
}
source
share