The Metamodel Generator or Query Validator must be enabled as an annotation processor in the project build. Otherwise, if neither is enabled, this annotation has no effect.
If only the Metamodel Generator is enabled, only arguments to the following annotations are validated:
Otherwise, if the Query validator is enabled, then, within the
scope annotated @CheckHQL, any static string argument to
any one of the following methods is interpreted as HQL/JPQL and
validated:
jakarta.persistence.EntityManager#createQuery(String, Class) ,
jakarta.persistence.EntityManager#createQuery(String) ,
org.hibernate.Session#createSelectionQuery(String, Class) , or
org.hibernate.Session#createMutationQuery(String)
The entity classes referred to by the queries must be annotated
with basic JPA metadata annotations like @Entity,
@ManyToOne, @Embeddable, @MappedSuperclass,
@ElementCollection, and @Access. Metadata specified
in XML mapping documents is ignored by the query validator.
Syntax errors, unknown entity names and unknown entity member names, and typing errors all result in compile-time errors.
Implementation Note
The static HQL type checker is not aware of metadata defined purely in XML, nor of JPA converters, and therefore sometimes reports false positives. That is, it rejects queries at compile time that would be accepted at runtime.
Therefore, by default, HQL specified in NamedQuery
annotations is always validated for both syntax and semantics,
but only illegal syntax is reported with severity
javax.. Problems with the
semantics of HQL named queries (typing problem) are reported to
the Java compiler by the Metamodel Generator with severity
javax..
So, actually, the effect of CheckHQL is only to change
the severity of reported problem.
jakarta.persistence.NamedQuery#query() , jakarta.persistence.EntityManager#createQuery(String, Class) , org.hibernate.Session#createSelectionQuery(String, Class)
| Modifier and Type | Method and Description |
|---|---|
| public Class |
| dialect | back to summary |
|---|---|
| public Class A Hibernate dialect to use.
| |