Skip to content

Commit 902355d

Browse files
committed
javadoc for creation contexts
1 parent da8a13b commit 902355d

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

hibernate-core/src/main/java/org/hibernate/metamodel/mapping/ordering/ast/OrderingExpression.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static Expression applyCollation(
5454
final SqmToSqlAstConverter converter =
5555
creationState instanceof SqmToSqlAstConverter sqmToSqlAstConverter
5656
? sqmToSqlAstConverter
57-
: new FakeSqmToSqlAstConverter(creationState);
57+
: new FakeSqmToSqlAstConverter( creationState );
5858
sortExpression =
5959
queryEngine.getSqmFunctionRegistry()
6060
.findFunctionDescriptor( "collate" )

hibernate-core/src/main/java/org/hibernate/query/sqm/spi/SqmCreationContext.java

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,59 @@
1313

1414
/**
1515
* The context in which all SQM creations occur.
16+
* <p>
17+
* Since we need to be able to parse and type check queries completely
18+
* outside the usual lifecycle of a Hibernate {@code SessionFactory},
19+
* it's extremely important that code which builds SQM trees does not
20+
* access the factory or other services or object not exposed by this
21+
* context object.
1622
*
1723
* @author Steve Ebersole
1824
*/
1925
@Incubating
2026
public interface SqmCreationContext extends BindingContext {
27+
28+
/**
29+
* The {@link QueryEngine}.
30+
*/
2131
QueryEngine getQueryEngine();
2232

33+
/**
34+
* The {@link NodeBuilder}.
35+
*/
2336
default NodeBuilder getNodeBuilder() {
2437
return getQueryEngine().getCriteriaBuilder();
2538
}
2639

2740
/**
41+
* Obtain a Java class object with the given fully-qualified
42+
* name. This method may only be used for unmanaged types,
43+
* for example, for {@code select new}, or for references to
44+
* {@code static final} constants or to {@code enum} values.
45+
*
2846
* @apiNote Avoid calling this method, since {@link Class}
2947
* objects are not available to the query validator
30-
* in Hibernate Processor at compilation time.
48+
* in Hibernate Processor at compilation time. If
49+
* you must call it, be prepared to robustly handle
50+
* the case in which the class is not present, in
51+
* which case this method might return something
52+
* arbitrary like {@code Object[].class}.
3153
*/
3254
default Class<?> classForName(String className) {
3355
return getQueryEngine().getClassLoaderService().classForName( className );
3456
}
3557

58+
/**
59+
* The {@link MappingMetamodel}.
60+
*/
3661
@Override
3762
default MappingMetamodel getMappingMetamodel() {
3863
return getQueryEngine().getMappingMetamodel();
3964
}
4065

66+
/**
67+
* The {@link JpaMetamodel}.
68+
*/
4169
@Override
4270
default JpaMetamodel getJpaMetamodel() {
4371
return getQueryEngine().getJpaMetamodel();

hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlAstCreationContext.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,14 @@
1313
import org.hibernate.type.descriptor.WrapperOptions;
1414

1515
/**
16-
* The "context" in which creation of SQL AST occurs. Provides
16+
* The "context" in which creation of SQL AST occurs. Provides
1717
* access to stuff generally needed when creating SQL AST nodes
18+
* <p>
19+
* Because we would like to be able to render SQL during the
20+
* startup cycle, before the {@code SessionFactory} is completely
21+
* initialized, code involved in SQL AST creation and rendering
22+
* should avoid making use of the {@code SessionFactory}.
23+
* Instead, use the objects exposed by this creation context.
1824
*
1925
* @author Steve Ebersole
2026
*/

0 commit comments

Comments
 (0)