more info about the metamodel in the javadoc for SessionFactory

This commit is contained in:
Gavin King 2023-07-16 15:39:20 +02:00
parent 5cee742698
commit 4d005b3d19
1 changed files with 19 additions and 1 deletions

View File

@ -88,12 +88,30 @@ import static org.hibernate.internal.TransactionManagement.manageTransaction;
* used in a sophisticated way by libraries or frameworks to implement generic
* concerns involving entity classes.
* <p>
* When the Metamodel Generator is used, elements of this metamodel may also
* be obtained in a typesafe way, via the generated metamodel classes. For
* an entity class {@code Book}, the generated {@code Book_} class has:
* <ul>
* <li>a single member named {@code class_} of type
* {@link jakarta.persistence.metamodel.EntityType EntityType&lt;Book&gt;},
* and
* <li>a member for each persistent attribute of {@code Book}, for example,
* {@code title} of type {@link jakarta.persistence.metamodel.SingularAttribute
* SingularAttribute&lt;Book,String&gt;}.
* </ul>
* <p>
* Use of these statically-typed metamodel references is the preferred way of
* working with the {@linkplain jakarta.persistence.criteria.CriteriaBuilder
* criteria query API}, and with {@linkplain EntityGraph}s.
* <p>
* The factory also {@linkplain #getSchemaManager() provides} a
* {@link SchemaManager} which allows, as a convenience for writing tests:
* <ul>
* <li>programmatic {@linkplain SchemaManager#exportMappedObjects(boolean)
* schema export} and {@linkplain SchemaManager#dropMappedObjects(boolean)
* schema removal}, and
* schema removal},
* <li>schema {@linkplain SchemaManager#validateMappedObjects() validation},
* and
* <li>an operation for {@linkplain SchemaManager#truncateMappedObjects()
* cleaning up} data left behind by tests.
* </ul>