Is it possible to map a table name for a domain object dynamically in grails?

后端 未结 2 718
北海茫月
北海茫月 2020-12-15 13:37

I have a domain that looks something like

class Foo {

  String name

  static mapping = {
     table \'foo\'    
  }
}

but I want to make

2条回答
  •  青春惊慌失措
    2020-12-15 14:17

    I don't think that's possible. Upon application startup, the mapping closure is evaluated and Hibernate mapping are generated as a result. This happens once upon startup, so dynamic resolution will not occur.

    Something comparable is done in the multi-tenant-core plugin, using the 'single tenant' setup, you have a seperate database for each tenant.

提交回复
热议问题