Skip to content

Commit f3ca2d6

Browse files
committed
talk about the MetamodelGenerator in Configuration
since it's used in two places now
1 parent 55d4f0f commit f3ca2d6

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

documentation/src/main/asciidoc/introduction/Configuration.adoc

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ Where `{version}` is the latest version of the JDBC driver for your databse.
8484
:validator: https://hibernate.org/validator
8585
:ehcache: https://www.ehcache.org
8686
:infinispan: https://infinispan.org
87+
:generator: https://hibernate.org/orm/tooling/
8788

8889
Optionally, you might also add any of the following additional features:
8990

@@ -94,7 +95,7 @@ Optionally, you might also add any of the following additional features:
9495

9596
| An {slf4j}[SLF4J] logging implementation | `org.apache.logging.log4j:log4j-core` or `org.slf4j:slf4j-jdk14`
9697
| A JDBC connection pool, for example, {agroal}[Agroal] | `org.hibernate.orm:hibernate-agroal` and `io.agroal:agroal-pool`
97-
| The Hibernate metamodel generator, if you're using the JPA criteria query API | `org.hibernate.orm:hibernate-jpamodelgen`
98+
| The {generator}[Hibernate Metamodel Generator], especially if you're using the JPA criteria query API | `org.hibernate.orm:hibernate-jpamodelgen`
9899
| {validator}[Hibernate Validator] | `org.hibernate.validator:hibernate-validator` and `org.glassfish:jakarta.el`
99100
| Local second-level cache support via JCache and {ehcache}[EHCache] | `org.hibernate.orm:hibernate-jcache` along with `org.ehcache:ehcache`
100101
| Distributed second-level cache support via {infinispan}[Infinispan] | `org.infinispan:infinispan-hibernate-cache-v60`
@@ -104,7 +105,24 @@ Optionally, you might also add any of the following additional features:
104105
|===
105106

106107
You might also add the Hibernate {enhancer}[bytecode enhancer] to your
107-
Gradle build if you want to use field-level lazy fetching.
108+
Gradle build if you want to use <<bytecode-enhancer,field-level lazy fetching>>.
109+
110+
[[metamodel-generator]]
111+
.The Metamodel Generator
112+
****
113+
114+
:generator-guide: {userGuideBase}#tooling-modelgen
115+
116+
Hibernate's {generator}[Metamodel Generator] is an annotation processor that produces what JPA calls a _static metamodel_.
117+
That is, it produces a typed model of the persistent classes in our program, giving us a type-safe way to refer to their attributes in Java code.
118+
In particular, it lets us specify <<entity-graph,entity graphs>> and <<criteria-queries,criteria queries>> in a completely type-safe way.
119+
120+
We've already seen how to set up the annotation processor in the <<hello-hibernate,gradle build>> we saw earlier.
121+
122+
Now, you don't have to use the Metamodel Generator with Hibernate—the APIs we just mentioned also accept plain strings—but we find that it works well with gradle and integrates well with our IDE, and the advantage in typesafety is compelling.
123+
124+
You can find more information in the {generator-guide}[User Guide].
125+
****
108126

109127
[[configuration-jpa]]
110128
=== Configuration using JPA XML

documentation/src/main/asciidoc/introduction/Interacting.adoc

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,7 @@ This results in a SQL query with _four_ ``left outer join``s.
382382

383383
[NOTE]
384384
====
385-
In the code examples above, we're making use of the JPA static metamodel.
386-
The classes `Book_` and `Author_` are generated by the annotation processor we have in our <<hello-hibernate,gradle build>>, one of the <<optional-dependencies,optional dependencies>> of Hibernate.
385+
In the code examples above, The classes `Book_` and `Author_` are generated by the <<metamodel-generator,JPA Metamodel Generator>> we saw earlier.
387386
They let us refer to attributes of our model in a completely type-safe way.
388387
We'll use them again, below, when we talk about <<criteria-queries>>.
389388
====
@@ -649,11 +648,7 @@ query.select(book).where(where)
649648
.orderBy(cb.asc(book.get(Book_.title)));
650649
----
651650

652-
:generator: https://hibernate.org/orm/tooling/
653-
:generator-guide: {userGuideBase}#tooling-modelgen
654-
655-
Here, the classes `Book_` and `Author_` are classes generated by Hibernate's {generator}[JPA Metamodel Generator], which is documented in the {generator-guide}[User Guide].
656-
They let us refer to attributes of our entities in a typesafe way.
651+
Here, as before, the classes `Book_` and `Author_` are generated by Hibernate's <<metamodel-generator,JPA Metamodel Generator>>.
657652

658653
[CAUTION]
659654
// .Injection attacks and criteria queries

0 commit comments

Comments
 (0)