From 00a940dafc1da1ee668925d330e74aa14a6027eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Mon, 30 Sep 2024 16:13:39 +0200 Subject: [PATCH] Update Hibernate ORM's "active" documentation For consistency with datasource documentation. --- docs/src/main/asciidoc/hibernate-orm.adoc | 6 ++++-- .../runtime/HibernateOrmRuntimeConfigPersistenceUnit.java | 4 ---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/src/main/asciidoc/hibernate-orm.adoc b/docs/src/main/asciidoc/hibernate-orm.adoc index e248b29fdcbc7b..e29f0110abf586 100644 --- a/docs/src/main/asciidoc/hibernate-orm.adoc +++ b/docs/src/main/asciidoc/hibernate-orm.adoc @@ -506,8 +506,10 @@ by default it is active at runtime, that is Quarkus will start the corresponding Hibernate ORM `SessionFactory` on application startup. To deactivate a persistence unit at runtime, set `quarkus.hibernate-orm[.optional name].active` to `false`. -Then Quarkus will not start the corresponding Hibernate ORM `SessionFactory` on application startup. -Any attempt to use the corresponding persistence unit at runtime will fail with a clear error message. +If a persistence unit is not active: + +* The `SessionFactory` will not start during application startup. +* Accessing the `EntityManagerFactory`/`EntityManager` or `SessionFactory`/`Session` will cause an exception to be thrown. This is in particular useful when you want an application to be able to xref:datasource.adoc#datasource-active[use one of a pre-determined set of datasources at runtime]. diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/HibernateOrmRuntimeConfigPersistenceUnit.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/HibernateOrmRuntimeConfigPersistenceUnit.java index 09cafed1b27fb1..279ac0e2944586 100644 --- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/HibernateOrmRuntimeConfigPersistenceUnit.java +++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/HibernateOrmRuntimeConfigPersistenceUnit.java @@ -23,10 +23,6 @@ public interface HibernateOrmRuntimeConfigPersistenceUnit { * * See xref:hibernate-orm.adoc#persistence-unit-active[this section of the documentation]. * - * If the persistence unit is not active, it won't start with the application, - * and accessing the corresponding EntityManagerFactory/EntityManager or SessionFactory/Session - * will not be possible. - * * Note that if Hibernate ORM is disabled (i.e. `quarkus.hibernate-orm.enabled` is set to `false`), * all persistence units are deactivated, and setting this property to `true` will fail. *