You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/main/asciidoc/hibernate-orm.adoc
+39-1Lines changed: 39 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -464,7 +464,10 @@ using the `@PersistenceUnit` annotation at the class level is not supported in t
464
464
465
465
Note that, similarly to what we do with the configuration property, we take into account the annotated package but also all its subpackages.
466
466
467
-
==== CDI integration
467
+
=== CDI integration
468
+
469
+
[[injecting-entry-points]]
470
+
==== Injecting entry points
468
471
469
472
If you are familiar with using Hibernate ORM in Quarkus, you probably already have injected the `EntityManager` using CDI:
470
473
@@ -540,6 +543,40 @@ These components can also be injected with a specific persistence unit qualifier
540
543
CriteriaBuilder criteriaBuilder;
541
544
----
542
545
546
+
[[plugging-in-converters-entity-listeners]]
547
+
==== Plugging in converters and entity listeners
548
+
549
+
The Quarkus extension for Hibernate ORM supports injecting link:{hibernate-orm-docs-url}#basic-jpa-convert[attribute converters] and link:{hibernate-orm-docs-url}#events-jpa-callbacks[entity listeners] into Hibernate ORM.
550
+
551
+
Just use them as you would in vanilla Hibernate ORM (see documentation linked above), and rely on CDI features (`@Inject`, `@PostConstruct`, `@PreDestroy`, ...) in the converter/listener implementation as needed.
552
+
553
+
When no CDI scope is specified, the converter/listener will behave as if it was `@Dependent` and will be instantiated once per persistence unit it's used in.
554
+
555
+
You can force a CDI scope by annotating the converter/listener class with for example `@ApplicationScoped`.
556
+
557
+
In very exotic scenarios, if you need to prevent usage of CDI in a converter/listener even though it uses CDI annotations (`@Inject`, ...), annotate it with `@Vetoed`. The class will then be instantiated by Hibernate ORM through its default constructor.
558
+
559
+
[[plugging-in-other-custom-components]]
560
+
==== Plugging in other custom components
561
+
562
+
The Quarkus extension for Hibernate ORM will automatically
563
+
inject components annotated with `@PersistenceUnitExtension` into Hibernate Search.
564
+
565
+
The annotation can optionally target a specific persistence unit with `@PersistenceUnitExtension(name = "nameOfYourPU")`.
566
+
567
+
This feature is available for the following component types:
If you need a more dynamic configuration for the different tenants you want to support and don't want to end up with multiple entries in your configuration file,
0 commit comments