-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
None
~Opening as draft because this is based on #48726, which must be merged first.~ => Done
This should be neutral for most applications.
It will impact applications that depend on the Hibernate ORM extension without defining any entity (no `orm.xml`, no `hbm.xml`, no class annotated with `@Entity`). These applications will now start Hibernate ORM, whereas they would previously have skipped starting it.
If the extension configuration is valid, this will allow running e.g. native queries using `Session` or (preferably) `StatelessSession`.
If the extension configuration is invalid (missing datasource, ...) this might result in errors.
The extension can still be disabled explicitly by setting `quarkus.hibernate-orm.enabled=false`, which will be approximately the same as not defining any entity before this patch – except some native image configuration might get skipped.
Note: I added automatic deactivation to persistence units, to limit the impact on existing applications: if a PU has no entity and the datasource is deactivated (no JDBC URL, ...) at runtime, then the PU will get deactivated automatically too, which in practice means the `SessionFactory` won't start and the user won't notice the change as long as they don't try to inject it anywhere.
- Fixes: #7148
Migration guide entry:
`````asciidoc
== Hibernate ORM
[[hibernate-orm-no-entity]]
=== Hibernate ORM enabled even no entities are defined
Quarkus will now start Hibernate ORM even if no Hibernate/JPA entities are defined, provided the Hibernate ORM extension is in the classpath and the persistence unit's datasource is configured (URL set, ...).
This allows running native queries through Hibernate ORM in particular.
To forcefully disable Hibernate ORM at build time even if the extension is in your classpath, set `quarkus.hibernate-orm.enabled` to `false`.
To only prevent Hibernate ORM from starting at runtime (e.g. in certain deployments only), set `quarkus.hibernate-orm.active` or `quarkus.hibernate-orm."persistence-unit-name".active` to `false`.
== Hibernate Reactive
[[hibernate-reactive-no-entity]]
=== Hibernate Reactive enabled even no entities are defined
Quarkus will now start Hibernate Reactive even if no Hibernate/JPA entities are defined, provided the Hibernate Reactive extension is in the classpath and the persistence unit's (reactive) datasource is configured (URL set, ...).
This allows running native queries through Hibernate Reactive in particular.
To forcefully disable Hibernate ORM/Reactive at build time even if the extension is in your classpath, set `quarkus.hibernate-orm.enabled` to `false`.
To only prevent Hibernate ORM/Reactive from starting at runtime (e.g. in certain deployments only), set `quarkus.hibernate-orm.active` or `quarkus.hibernate-orm."persistence-unit-name".active` to `false`.
`````