It is possible. You can add a Hibernate interceptor to process all SQL statements and parse / replace some token in the table name that you enter when matching with the actual table name that you want to use.
src / groovy / DynamicTableNameInterceptor.groovy:
import org.hibernate.EmptyInterceptor public class DynamicTableNameInterceptor extends EmptyInterceptor { public String onPrepareStatement(String sql) {
Grails app / CONF / spring / resources.groovy:
beans = { // This is for Grails 1.3.x , in previous versions, the bean name is eventTriggeringInterceptor entityInterceptor(DynamicTableNameInterceptor) }
source share