Skip to content

Make it possible to start without connecting to the database #47695

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.JdbcSettings;
import org.hibernate.jpa.HibernateHints;
import org.hibernate.jpa.boot.spi.EntityManagerFactoryBuilder;
import org.hibernate.jpa.boot.spi.PersistenceUnitDescriptor;
Expand Down Expand Up @@ -228,8 +229,10 @@ private RuntimeSettings buildRuntimeSettings(String persistenceUnitName, Recorde
}
}

// Allow detection of driver/database capabilities on runtime init (was disabled during static init)
runtimeSettingsBuilder.put("hibernate.boot.allow_jdbc_metadata_access", "true");
// Allow detection of driver/database capabilities on runtime init if required
// (was disabled during static init)
runtimeSettingsBuilder.put(JdbcSettings.ALLOW_METADATA_ON_BOOT,
String.valueOf(!persistenceUnitConfig.database().startOffline()));

if (!persistenceUnitConfig.unsupportedProperties().isEmpty()) {
log.warnf("Persistence-unit [%s] sets unsupported properties."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ interface HibernateOrmConfigPersistenceUnitDatabase {
@WithName("version-check.enabled")
@ConfigDocDefault("`true` if the dialect was set automatically by Quarkus, `false` if it was set explicitly")
Optional<Boolean> versionCheckEnabled();

@WithDefault("false")
boolean startOffline();
}

@ConfigGroup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ public QuarkusRuntimeInitDialectFactoryInitiator(String persistenceUnitName,
// TODO change the default to "always enabled" when we solve version detection problems
// See https://github.com/quarkusio/quarkus/issues/43703
// See https://github.com/quarkusio/quarkus/issues/42255
// TODO disable the check by default when offline startup is opted in
// See https://github.com/quarkusio/quarkus/issues/13522
.orElse(recordedConfig.getExplicitDialect().isEmpty());
// Disable on offline startup
.orElse(!runtimePuConfig.database().startOffline() && recordedConfig.getExplicitDialect().isEmpty());
}

@Override
Expand Down