Sachin Verma
Sachin Verma

Reputation: 3802

Grails changing datasource at runtime

I was asked to implement a logic for having separate domains for a separate user (assuming he will have his own database) means all the domains will be mapped to different database at runtime. Sounds silly i know

How can i change the datasouce(persistence configuration file) after logIn of user while datasource are supposed to load at startup time of application.

Is it possible somehow?

NOTE: I want to change datasource of some domain to another datasource at runtime one at a time.

Upvotes: 0

Views: 1624

Answers (1)

user1791574
user1791574

Reputation: 1749

You can map multiple data sources in your DataSource.groovy file and you can create multi talented domain classes and then you can perform any CRUD operations among these data sources at runtime.

References

Upvotes: 2

Related Questions