datasources = { datasource(name: 'ds2'){ domainClasses([org.openlab.settings.GlobalSetting, org.openlab.settings.UserSetting, org.openlab.security.Requestmap]) pooled(true) driverClassName('org.hsqldb.jdbcDriver') url('jdbc:hsqldb:mem:devDB') username('sa') password('') dbCreate('create-drop') hibernate { cache { use_second_level_cache(false) use_query_cache(false) } } } }
The usual datasource configuration remains intact and is the core or default database. In datasources.groovy you can define as many additional databases as you like. You only have to follow this pattern where the hibernate information is included as well as the definition of domain classes you wish to store in the new database.
The clear distribution of domain classes to datasources makes this approach easy and the only thing you have to consider are foreign key relations when separating the wrong domain classes.
No comments:
Post a Comment