postgresql - Spring-boot JPA connect to postgres where database and schema are provided at runtime -


i building multi-tenant application, tenant database configuration stored in redis. based on request, query redis database , schema configured tenant, application built on spring boot.

i took @ spring boot's jpa sample, , did more google find suitable solution this, unfortunately, couldn't find one.

is possible use jpa sample provided here ? https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-data-jpa

please suggest me other best possible way tackle problem

thanks

spring data jpa uses jpa annotations define domain model. these jpa entities define schema database. can't change these entities, nor db schema on runtime.

so no, updating schema on runtime not possible spring boot + spring data jpa combo.

database connection (e.g. db url, username password) more flexible. need create datasource beans programmatically , somehow programatically define data source use each query per tenant. wasn't requirement of spring nor jpa ecosystem, therefore may face lot of issues.

i working on such system before, using plain sql queries via jdbc , creating db connection programatically achieve schema changes on runtime.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -