Grails GORM on several forms

I usually use a one-to-many relationship as follows:

class Study {
    static hasMany = [ crfs : Crf ]
    String name 
    ...
} 

class Crf { 
String title
String info 
...
} 

I can extend this relationship to other domains, Ex:

static hasMany = [ crfs : Crf, crfb : CrfBlood ...]

But in my case, I need to associate the Study domain with 30 other domains, maybe more ... (for example: CrfBlood, CrfMedical, crfFamily, etc.).

What domain model implementation should I use in my case?
I would like to maintain the usability of dynamic crawlers in my project.

Update - addition to the model:

A -- .
-- Crfs (: CrfBlood, CrfMedical, crfFamily ..).
-- (: ).

Crfs , GORM ( ) static hasMany = [...] ?
, , , hasMany?

+3
1

Crf Crf, Study, .

class Crf {
    String title
    String info
}

class CrfBlood extends Crf {
    String detailBlood
}

class CrfMedical extends Crf {
    String detailMedical
}

class Study {
    String name
    static hasMany = [ crfs: Crf ]
}

:

def s = new Study(...)
def c1 = new CrfBlood(...)
def c2 = new CrfMedical(...)
s.addToCrfs(c1)
s.addToCrfs(c2)
0

Source: https://habr.com/ru/post/1792671/


All Articles