callistaenterprise / blog-multitenancy Goto Github PK
View Code? Open in Web Editor NEWSample application demonstrating dynamic Multi-tenancy with Spring Boot, Hibernate and Liquibase
License: Apache License 2.0
Sample application demonstrating dynamic Multi-tenancy with Spring Boot, Hibernate and Liquibase
License: Apache License 2.0
Hi,
First of all, thank you for publishing this project.
I am trying to use your project as a reference to introduce Multitenancy to Postgres in my project.
I have tried to test your implementation but I am running into an error in both services when I run the maven run command out of the box:
2022-11-14 08:11:03.864 INFO 9419 --- [ restartedMain] micSchemaBasedMultiTenantSpringLiquibase : Schema based multitenancy enabled 2022-11-14 08:11:03.900 WARN 9419 --- [ restartedMain] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 0, SQLState: 42P01 2022-11-14 08:11:03.900 ERROR 9419 --- [ restartedMain] o.h.engine.jdbc.spi.SqlExceptionHelper : ERROR: relation "tenant" does not exist Position: 79 2022-11-14 08:11:03.907 WARN 9419 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tenantLiquibase' defined in class path resource [se/callista/blog/service/multitenancy/config/tenant/TenantLiquibaseConfig.class]: Invocation of init method failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet
2022-11-14 08:06:20.572 WARN 8710 --- [ restartedMain] onfigReactiveWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tenantLiquibase' defined in class path resource [se/callista/blog/service/multitenancy/config/tenant/TenantLiquibaseConfig.class]: Invocation of init method failed; nested exception is org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [SELECT * FROM Tenant]; nested exception is org.postgresql.util.PSQLException: ERROR: relation "tenant" does not exist Position: 15
it seems that in both services, the application cannot find the tenant table (tenant table and related schema were not created) which is supposed to be in the master repository where tenant-related information is saved. I am expecting that at least a schema is created automatically at startup which contains the tenant table, but this is not the case.
did I miss doing some configuration here or am I misunderstanding / forgetting something?
When i execute the cURL command, i get the below error. Not sure what is the issue, i tried removing the Lombak dependencies from the ProductValue class but still no success.
curl -H "X-TENANT-ID: tenant1" -H "Content-Type: application/se.callista.blog.service.api.product.v1_0+json" -X POST -d '{"name":"Product 1"}' localhost:8080/products
2020-12-08 20:46:30.335 WARN 13848 --- [nio-8080-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/se.callista.blog.service.api.product.v1_0+json;charset=UTF-8' not supported]
2020-12-08 20:46:30.365 WARN 13848 --- [nio-8080-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotWritableException: No converter found for return value of type: class java.util.LinkedHashMap]
Can you create a separate db + multi schema variation?
For example, one tenant might use the db by itself, but smaller tenants may reside in the same db, but in its own schema.
Hi
the tests on the Service layer don't appear to work.
If I run: mvn '-Dtest=se.callista.blog.tenant_management.service.*.Test' test
it produces an error relating to no tests found...
thanks for your great article first. could you detail the Hibernate 6.0 new feature @TenantID implementing sample ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.