如何在grails域类中使用arraylist

如何在grails域类中使用arraylist,grails,Grails,我不熟悉grails。我有以下要求,如何实现 class File { list<Employee> listOfCaseWorkersWhoHaveWorkedOnThisFile; <<<---- how to achieve this ? static constraints = { } } class Employee { list<File> filesOwnedByHim <<<<

我不熟悉grails。我有以下要求,如何实现

class File {
    list<Employee> listOfCaseWorkersWhoHaveWorkedOnThisFile;  <<<---- how to achieve this ? 

    static constraints = {
    }
}

class Employee {
    list<File> filesOwnedByHim <<<<<-------- also this ?

    static constraints = {
    }
}
类文件{

列出处理过该文件的CaseWorkers列表;您可以使用
hasMany
,它是类之间的一对多关联

class File {
    static hasMany = [employees: Employee]

    static constraints = {
    }
}

class Employee {
    static hasMany = [files: File]

    static constraints = {
    }
}
然后,您可以轻松地对其使用GORM操作(addTo、findBy等)

参考: