|
13 | 13 |
|
14 | 14 | /**
|
15 | 15 | * 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. |
16 | 22 | *
|
17 | 23 | * @author Steve Ebersole
|
18 | 24 | */
|
19 | 25 | @Incubating
|
20 | 26 | public interface SqmCreationContext extends BindingContext {
|
| 27 | + |
| 28 | + /** |
| 29 | + * The {@link QueryEngine}. |
| 30 | + */ |
21 | 31 | QueryEngine getQueryEngine();
|
22 | 32 |
|
| 33 | + /** |
| 34 | + * The {@link NodeBuilder}. |
| 35 | + */ |
23 | 36 | default NodeBuilder getNodeBuilder() {
|
24 | 37 | return getQueryEngine().getCriteriaBuilder();
|
25 | 38 | }
|
26 | 39 |
|
27 | 40 | /**
|
| 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 | + * |
28 | 46 | * @apiNote Avoid calling this method, since {@link Class}
|
29 | 47 | * 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}. |
31 | 53 | */
|
32 | 54 | default Class<?> classForName(String className) {
|
33 | 55 | return getQueryEngine().getClassLoaderService().classForName( className );
|
34 | 56 | }
|
35 | 57 |
|
| 58 | + /** |
| 59 | + * The {@link MappingMetamodel}. |
| 60 | + */ |
36 | 61 | @Override
|
37 | 62 | default MappingMetamodel getMappingMetamodel() {
|
38 | 63 | return getQueryEngine().getMappingMetamodel();
|
39 | 64 | }
|
40 | 65 |
|
| 66 | + /** |
| 67 | + * The {@link JpaMetamodel}. |
| 68 | + */ |
41 | 69 | @Override
|
42 | 70 | default JpaMetamodel getJpaMetamodel() {
|
43 | 71 | return getQueryEngine().getJpaMetamodel();
|
|
0 commit comments