List of Strings in a Grails domain class

瘦欲@ 提交于 2019-12-06 05:59:16
user190117

You can achieve this by using hasMany. Furthermore you need to define books as a List since without it you would get a simple Set that does not allow any duplicates.

class Catalogue {
    static hasMany = [books: String]
    List books
}

Create a domain Book class:

class Book {
 String title
 String isbn
 ...

String toString(){
  return "${title}" 
 }

}

and modify your Catalogue as

class Catalogue{
  String name
  ....
  static hasMany = [books: Book]
  //etc etc 
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!