Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage of DatabaseEnginePool creates complexity to hold entities and prepared statement in memory #290

Open
artpdr opened this issue Jan 25, 2022 · 1 comment

Comments

@artpdr
Copy link
Collaborator

artpdr commented Jan 25, 2022

DatabaseEnginePool contains a pool of DatabaseEngine. However, each of these Database Engines may have different entities and prepared statements in memory if we don't propagate the entities and prepared statements to all DatabaseEngines in the pool.

To deal with this, every time that I do a DatabaseEnginePool#borrow I need to do a DatabaseEngine#loadEntity if I want to persist an entity. Otherwise, doing a DatabaseEngine#persist will throw an exception if the entity on that DatabaseEngine wasn't loaded yet.
In relation to the prepared statements, every time I do a DatabaseEnginePool#borrow to do an operation using a prepared statement (e.g. DatabaseEngine#executePSUpdate), I need to perform a check to see if a prepared statement exists or create it (DatabaseEngine#preparedStatementExists and DatabaseEngine#createPreparedStatement).

Can we have a way to set the entities and prepared statements globally inside the DatabaseEnginePool and use that on every DatabaseEngine from the pool? At the moment, we can use a Function on the DatabaseEnginePool#getConnectionPool to run some action on the DatabaseEngines returned from the pool where we could register the prepared statements and entities but this needs to be done when we create the DatabaseEnginePool and not after. Hence, it would require information to be passed outside of the scope where the pool will be necessary. IMO we should be able to update the context associated with the DatabaseEngines that exist in the pool, even after the pool is created. This prevents leakage of information from classes using DatabaseEngines from the pool.

@artpdr
Copy link
Collaborator Author

artpdr commented Jan 25, 2022

FYI @francisco-polaco ☝️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant