quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.73k stars 2.67k forks source link

Hibernate ORM with Multitenancy and TenantConnectionResolver default datasource #18130

Closed robp94 closed 3 years ago

robp94 commented 3 years ago

Describe the bug

When using Hibernate ORM with Multitenancy and a CustomTenantConnectionResolver like described here, I noticed that Quarkus does not start as long as I do not specify a jdbc url for the default datasource in the application.properties. Why isn't org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider#getAnyConnection used for this? Or do you have to configure something else for this?

Expected behavior

Quarkus should start and use the default datasource specified via getAnyConnection.

Actual behavior

Quarkus does not start or you need to define the datasource in the application.properties

To Reproduce

Link to a small reproducer (preferably a Maven project if the issue is not Gradle-specific).

Or attach an archive containing the reproducer to the issue. code-with-quarkus.zip

Steps to reproduce the behavior:

  1. Without jdbc url defined start the the application -> application won't start
  2. Add an jdbc url to application.properties and start the applicaytion -> application will start but uses the the datasource from application.properties and does not resolve it programmatically

Configuration

# Add your application.properties here, if applicable.
quarkus.hibernate-orm.database.generation=none
quarkus.hibernate-orm.multitenant=DATABASE
quarkus.datasource.devservices=false

quarkus.datasource.db-kind=postgresql
#quarkus.datasource.username=postgres
#quarkus.datasource.password=test

#quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/postgres

Screenshots

(If applicable, add screenshots to help explain your problem.)

Environment (please complete the following information):

Output of uname -a or ver

Microsoft Windows [Version 10.0.19043.1052]

Output of java -version

openjdk version "11.0.11" 2021-04-20 OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9) OpenJDK 64-Bit Server VM AdoptOpenJDK-11.0.11+9 (build 11.0.11+9, mixed mode)

Quarkus version or git rev

1.13.7.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Maven 3.8.1

Additional context

(Add any other context about the problem here.)

quarkus-bot[bot] commented 3 years ago

/cc @Sanne, @gsmet, @yrodiere