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
| <<envers,Envers>>, for auditing historical data | `org.hibernate.orm:hibernate-envers`
124
124
| <<jfr,Hibernate JFR>>, for monitoring via Java Flight Recorder | `org.hibernate.orm:hibernate-jfr`
125
+
| Hibernate Jandex integration, for <<entity-discovery,entity discovery>> | `org.hibernate.orm:hibernate-scan-jandex`
125
126
|===
126
127
127
128
You might also add the Hibernate {enhancer}[bytecode enhancer] to your
@@ -264,6 +265,35 @@ This API is useful if you have very advanced requirements, for example, if you'r
264
265
You'll find more information in the {native-bootstrap}[User Guide], and in the {boot}[package-level documentation] of `org.hibernate.boot`.
265
266
****
266
267
268
+
[[entity-discovery]]
269
+
=== Entity discovery
270
+
271
+
In a Jakarta EE container environment, we don't usually need to list entity and embeddable classes explicitly in `persistence.xml`.
272
+
Instead, the container scans the persistence unit `jar` file and automatically discovers classes annotated `@Entity`, `@Embeddable`, or `@MappedSuperclass`.
273
+
274
+
`HibernatePersistenceConfiguration` offers the same functionality if the <<optional-dependencies,optional dependency>> `hibernate-scan-jandex` is available at runtime.
275
+
276
+
In the following code, entity classes available on the class loader which loaded `Main.class` are automatically discovered.
277
+
278
+
[source,java]
279
+
----
280
+
SessionFactory sessionFactory =
281
+
// entities discovered on ClassLoader of Main.class
282
+
new HibernatePersistenceConfiguration("Bookshop", Main.class)
0 commit comments