30 lines
1.6 KiB
Plaintext
30 lines
1.6 KiB
Plaintext
|
== SQM
|
||
|
|
||
|
The Semantic Query Model (SQM) is Hibernate's representation of an HQL or Criteria query's semantic (meaning). This
|
||
|
representation is modeled as an "abstract syntax tree" (AST) - meaning it is a structured tree of nodes where each node
|
||
|
represrents an atomic piece of the query. E.g. `SqmSelectClause` represents the query's select clause as you might
|
||
|
imagine. That `SqmSelectClause` is ultimately a collection of one or more `SqmSelection` references representing the
|
||
|
individual selections to be returned from the query (called the domain results).
|
||
|
|
||
|
=== The Model
|
||
|
|
||
|
This SQM model uses the Hibernate domain model, which is Hibernate's extension to the JPA model. This model contains no
|
||
|
relational mapping information, it simply describes the domain model in mostly Java terms although it does incorporate
|
||
|
"classifications" of the type system. E.g. it understand that `Customer` is an entity, but contains no information
|
||
|
about the tables it maps to nor its columns.
|
||
|
|
||
|
See the `design/type-system-domain.adoc` design doc. For details about this domain model
|
||
|
|
||
|
|
||
|
=== Building an SQM
|
||
|
|
||
|
|
||
|
=== Interpreting an SQM
|
||
|
|
||
|
Ultimately Hibernate needs to talk with the database to fulfill these query executions. This is currently a 2-step process.
|
||
|
|
||
|
First we convert the SQM into a new AST called the SQL AST. This is an AST that is more "SQL-y". It's nodes are defined
|
||
|
in terms of Hibernate's mapping model which is the model that actually does understand the relational mapping.
|
||
|
See `design/type-system-mapping.adoc` for details about this model. Part of this conversion step is to resolving
|
||
|
domain model references to mapping model references...
|