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

JdbcTemplate - Add support for multitenancy [SPR-17342] #21876

spring-issuemaster opened this issue Oct 4, 2018 · 2 comments


Copy link

@spring-issuemaster spring-issuemaster commented Oct 4, 2018

robert-niestroj opened SPR-17342 and commented

Please add support for multitenancy in JdbcTemplate.

Scenario: i have an app which uses JPA for CRUD, but for reporting uses native queries executed via JdbcTemplate. Hibernate in our app is working in multitenancy mode with the strategy per schema on MySQL. I tried several things but could not implement similar multitenancy in JdbcTemplate.

Basiclly i do connection.createStatement("USE " + tenantSchema ); in hibernates multitenancyConnectionProvider.


I would like to do something similar in JdbcTemplate.

Reference URL:


This comment has been minimized.

Copy link

@gokhanoner gokhanoner commented Jul 24, 2019

any update on this one?

One thing to mention, JDBC connection has setCatalog method, which can be used to change schema/database, since each DB driver interpret it differently based on to their model, MySQL call SET <schema>, PostgreSQL changes DB etc. This will be more generic solution. Like Hibernate, if Spring has a way of defining ConnectionProvider and TenantResolver for JdbcTemplate, this should work. I assume some changes needed internally as well, since Spring wrap original connection for Transaction tracking etc.


This comment has been minimized.

Copy link

@brankoiliccc brankoiliccc commented Aug 30, 2019

So this is just ridiculous. Basically JdbcTemplate is hard coded to be single tenant. Because of this we do not even use it, but there is a catch ! Spring team uses it so we have to write ton of our own implementations already provided by spring to not use JdbcTemplate. geez

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.