This package defines a semantic model of HQL queries.
Our implementation of the JPA
Semantic Query Model (SQM)An SQM is a tree representing the semantic interpretation of a query. It's "semantic" in the sense that it contains more information than a simple syntax tree.
HQLHQL is interpreted as an SQM with the help of an ANTRL-generated parser. The class
SemanticQueryBuilderis responsible for visiting the syntax tree produced by the parser and building an SQM.
Criteria queriesThe SQM tree nodes directly implement the JPA criteria query contracts. For example,
Our implementation of the JPA
CriteriaBuilder interface is
It instantiates SQM nodes and arranges them into SQM tree using the
standard operations for building a JPA criteria query.
Transforming SQM to SQLThe package
org.hibernate.sql.astdefines an AST representing SQL. To generate SQL from SQM, we must transform the SQM tree to a SQL AST tree. This process is described here, and is handled by a
Interface Summary Interface Description NodeBuilderAdapts the JPA CriteriaBuilder to generate SQM nodes. SemanticQueryWalker<T>Support for walking a Semantic Query Model (SQM) tree SqmExpressible<J>Anything in the application domain model that can be used in an SQM query as an expression SqmJoinable<O,E>Specialization for attributes that that can be used in creating SQM joins todo (6.0) : should we define this for entities as well to handle cross joins and "entity joins"? - the result type would need to change to just SqmJoin... SqmPathSource<J>Represents parts of the application's domain model that can be used to create
SqmSelectionQuery<R> SqmTreeCreationLoggerLogger used to log information about the creation of an SQM tree. SqmTreeTransformationLogger
Enum Summary Enum Description BinaryArithmeticOperatorEnumeration of standard binary arithmetic operators CastTypeDefines the set of basic types which should be accepted by the
cast()function on every platform.
ComparisonOperatorDefines the comparison operators. DynamicInstantiationNatureRepresents the type of instantiation to be performed. FetchClauseTypeThe kind of fetch to use for the
FrameExclusion FrameKind FrameMode IntervalTypeThe different types of intervals that SQL defines. NullOrderingThe order of null. NullPrecedenceDefines precedence of null values within
SetOperatorThe SQL set operators. SortOrder SqmQuerySourceInformational - used to identify the source of an SQM statement. StrictJpaComplianceViolation.Type TemporalUnitA temporal field type which can occur as an argument to
extract()or as the unit of a duration expression.
Exception Summary Exception Description AliasCollisionException InterpretationExceptionRepresents a general uncaught problem performing the interpretation. LiteralNumberFormatException ParsingExceptionThe root exception for errors (potential bugs) in the sqm parser code itself, as opposed to
SemanticExceptionwhich indicates problems with the query itself.
StrictJpaComplianceViolationIndicates violations of strict JPQL syntax while strict JPQL syntax checking was enabled. UnknownEntityExceptionIndicates we were not able to resolve a given "path structure" as an entity name. UnknownPathExceptiontodo (6.0) : account for this in the "exception conversion" handling