southpaul
southpaul

Reputation: 199

How to not share grails datasource across session?

We have a Grails project that is set up to where we change the dataSource's username, password, and url at runtime. The problem we are seeing is that the dataSource's properties are being changed across all sessions, causing issues when multiple users are in the application at the same time.

I have tried copying the dataSource and placing it in the session itself, but this did not work.

Is there a property on the dataSource for it to not be shared?

Upvotes: 1

Views: 70

Answers (1)

Burt Beckwith
Burt Beckwith

Reputation: 75681

The datasource is a singleton - it's registered as a Spring bean, and they are singletons by default. There is no way to change that at runtime, but you can create your own datasources however you like. There's a plugin that can help with this - http://grails.org/plugin/runtime-datasources

There is some documentation in the plugin's readme at Github: https://github.com/domurtag/runtime-datasources

Upvotes: 1

Related Questions