I have table named 'employee' which was exists in two databases with same columns.
For this table related CURD operations i have created one Domain class which is configured in Datasources.groovy to point to one of the db.
Now, my problem is, is there anyway to use this same single domain which can 开发者_StackOverflowbe pointed to both the databases so, that while executing GORM methos on that domain i will pass db name as parameter.
Thanks,
PavanI've never seen this done before and would be surprised if you could out of the box. Your options would be to override save()
etc on your Domain class and do it manually to the second database after you call super()
, or you could set up replication between your databases. The second option might be more desirable when it comes to data integrity.
I haven't tried this, but it sounds as you could solve your problem using the Grails Sharding plugin:
- Grails Sharding Plugin
- DZone Article: Sharding in Grails
精彩评论