-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Hibernate ORM - Database multitenancy example from documentation does not work #41754
Comments
Hello. Thanks for reporting.
The message:
The useful part in your case:
... i.e.: set
... i.e.: I tend to agree that the part about "configuring a datasource" is confusing; this should be talking about "setting property X to one of the datasources" instead, or maybe not be mentioned at all...
That's the wrong documentation, you should look into the one you mentioned initially, i.e.: https://quarkus.io/guides/hibernate-orm#database-approach ... and that documentation is indeed wrong, we need to fix it. The suggested configuration does not set the datasource nor the dialect, so it would not work. I'll send a PR soon to fix this. It doesn't help that multi-tenancy quickstarts are broken: #41759 . Let's try to address that as well... |
@yrodiere
But is has the side effect of starting a Postgres dev service container for nothing :) Note also that after making the datasources work, I've noticed that the flyway configuration is wrong in the documentation. I think it should be :
Maybe you should also name the folder 'database/default' to 'database/base', because it seems a bit weird and confusing not having the folder name maching the datasource name. To resume currently this works for me, with a datasource named 'a' and a datasource named 'b' :
|
I'm adding a little tip here for anyone who comes across this and who would like to use a schema approach but declare 2 datasources (in order to be able to have dedicated users for each schema, which is better for security in a multitenancy approach. The SCHEMA approach with a unique user for all schemas is not recommended in terms of security - Maybe this could be added to the documentation :)) :
In quarkus jus use -> Each user being the owner of its dedicated schema (schema 'a' for user 'user_a' and schema 'b' for user 'user_b'), the datasource will automatically be in the right schema when connecting to the database for each user. |
Describe the bug
Hi,
I'm trying to set up multitenancy using the DATABASE approach, as described here : https://quarkus.io/guides/hibernate-orm#multitenancy but it seems it is not working.
Here is my configuration :
But I'm getting this error at startup :
io.quarkus.runtime.configuration.ConfigurationException: The Hibernate ORM extension could not infer the dialect for persistence unit '<default>'. When using database multi-tenancy, you must either configure a datasource for that persistence unit (refer to https://quarkus.io/guides/datasource for guidance), or set the dialect explicitly through property 'quarkus.hibernate-orm.dialect'.
The error is not very clear and I cannot find any reference to 'quarkus.hibernate-orm.dialect' in https://quarkus.io/guides/datasource
Expected behavior
No response
Actual behavior
No response
How to Reproduce?
No response
Output of
uname -a
orver
Microsoft Windows [Version 10.0.19045.4529]
Output of
java -version
21.0.3
Quarkus version or git rev
3.12.1
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.9.6
Additional information
No response
The text was updated successfully, but these errors were encountered: