Typically, when defining a DAO, you should have a setter for the data source on the DAO object. My problem is that our data source is dynamically changing based on a server request. that is, each query can refer to a different instance of the database.
The query contains logical properties that can later be used to retrieve the connection to the query database.
Therefore, when a dependency injects a DAO into a business logic object, I need a way to set properties in the DAO at runtime (not configuration time).
One solution is to keep the data source in the stream local, but I don't really like messing with the local variables of the stream.
Another option is to have a business logic object initialization method that calls initialization in the DAO using query properties.
I assume this is a common problem, can you suggest a general solution?
Liorh source share