more work on design docs for SQM and SQL AST
This commit is contained in:
parent
0c6c8b4406
commit
293fc0fe54
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
Ultimately our goal here is to have a `JdbcOperation` object to be executed. Generally, that would look like this:
|
Ultimately our goal here is to have a `JdbcOperation` object to be executed. Generally, that would look like this:
|
||||||
|
|
||||||
````
|
[source]
|
||||||
|
----
|
||||||
final SelectStatement sqlAst = ...;
|
final SelectStatement sqlAst = ...;
|
||||||
|
|
||||||
final JdbcServices jdbcServices = sessionFactory.getJdbcServices();
|
final JdbcServices jdbcServices = sessionFactory.getJdbcServices();
|
||||||
|
@ -19,8 +20,7 @@ Ultimately our goal here is to have a `JdbcOperation` object to be executed. Ge
|
||||||
jdbcParameterBindings,
|
jdbcParameterBindings,
|
||||||
...
|
...
|
||||||
);
|
);
|
||||||
|
----
|
||||||
````
|
|
||||||
|
|
||||||
|
|
||||||
== The Tree
|
== The Tree
|
||||||
|
|
|
@ -2,9 +2,13 @@
|
||||||
|
|
||||||
The Semantic Query Model (SQM) is Hibernate's representation of an HQL or Criteria query's semantic (meaning). This
|
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
|
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
|
represents an atomic piece of the query. E.g. `SqmSelectClause` represents the query's select clause.
|
||||||
imagine. That `SqmSelectClause` is ultimately a collection of one or more `SqmSelection` references representing the
|
`SqmSelectClause` is ultimately a collection of one or more `SqmSelection` references representing the individual
|
||||||
individual selections to be returned from the query (called the domain results).
|
selections to be returned from the query (called the domain results). Etc
|
||||||
|
|
||||||
|
All of these details are handled by the `QuerySqmImpl` implementation of `Query`. This is what Hibernate
|
||||||
|
uses for both HQL and Criteria queries.
|
||||||
|
|
||||||
|
|
||||||
== The Tree
|
== The Tree
|
||||||
|
|
||||||
|
@ -18,14 +22,14 @@ See the `design/type-system-domain.adoc` design doc. For details about this dom
|
||||||
The tree model is defined in the package `org.hibernate.query.sqm.tree`
|
The tree model is defined in the package `org.hibernate.query.sqm.tree`
|
||||||
|
|
||||||
|
|
||||||
== Building an SQM
|
== Building an SQM - HQL
|
||||||
|
|
||||||
|
`org.hibernate.query.hql.HqlTranslator#translate`
|
||||||
|
|
||||||
|
|
||||||
=== HQL
|
== Building an SQM - Criteria
|
||||||
|
|
||||||
|
|
||||||
=== Criteria
|
|
||||||
|
|
||||||
|
`org.hibernate.query.sqm.internal.SqmCriteriaNodeBuilder`
|
||||||
|
|
||||||
|
|
||||||
== Translating an SQM
|
== Translating an SQM
|
||||||
|
@ -33,5 +37,19 @@ The tree model is defined in the package `org.hibernate.query.sqm.tree`
|
||||||
Generic support for walking over the SQM tree via the `org.hibernate.query.sqm.SemanticQueryWalker` contract.
|
Generic support for walking over the SQM tree via the `org.hibernate.query.sqm.SemanticQueryWalker` contract.
|
||||||
|
|
||||||
More specialized support specifically for translating the SQM into a SQL AST is also defined by
|
More specialized support specifically for translating the SQM into a SQL AST is also defined by
|
||||||
`org.hibernate.query.sqm.sql.SqmToSqlAstConverter`. The document `design/sql-ast.adoc` for details about the SQL AST,
|
`org.hibernate.query.sqm.sql.SqmToSqlAstConverter`.
|
||||||
including its execution.
|
|
||||||
|
[source]
|
||||||
|
----
|
||||||
|
final SessionFactoryImplementor sessionFactory = ...;
|
||||||
|
final QueryEngine queryEngine = sessionFactory.getQueryEngine();
|
||||||
|
|
||||||
|
final SqmTranslatorFactory sqmTranslatorFactory = queryEngine.getSqmTranslatorFactory();
|
||||||
|
|
||||||
|
final SqmSelectTranslator sqmConverter = sqmTranslatorFactory.createSelectTranslator( ... );
|
||||||
|
|
||||||
|
final SqmSelectTranslation interpretation = sqmConverter.translate( sqm );
|
||||||
|
----
|
||||||
|
|
||||||
|
|
||||||
|
See the document `design/sql-ast.adoc` for details about the SQL AST, including its execution.
|
||||||
|
|
Loading…
Reference in New Issue