|
4 | 4 | */
|
5 | 5 | package org.hibernate.query;
|
6 | 6 |
|
| 7 | +import jakarta.persistence.EntityGraph; |
7 | 8 | import org.hibernate.query.criteria.JpaCriteriaInsert;
|
8 | 9 |
|
9 | 10 | import jakarta.persistence.TypedQueryReference;
|
@@ -337,6 +338,43 @@ public interface QueryProducer {
|
337 | 338 | */
|
338 | 339 | <R> SelectionQuery<R> createSelectionQuery(String hqlString, Class<R> resultType);
|
339 | 340 |
|
| 341 | + /** |
| 342 | + * Create a {@link SelectionQuery} instance for the given HQL query |
| 343 | + * string and given {@link EntityGraph}, which is interpreted as a |
| 344 | + * {@linkplain org.hibernate.graph.GraphSemantic#LOAD load graph}. |
| 345 | + * The query result type is the root entity of the given graph. |
| 346 | + * <ul> |
| 347 | + * <li>If the query has an explicit {@code select} clause, there must |
| 348 | + * be a single item in the {@code select} list, and the select |
| 349 | + * item must be assignable to the root type of the given graph. |
| 350 | + * <li>Otherwise, if a query has no explicit {@code select} list, the |
| 351 | + * select list is inferred from the given entity graph. The query |
| 352 | + * must have exactly one root entity in the {@code from} clause, |
| 353 | + * it must be assignable to the root type of the given graph, and |
| 354 | + * the inferred select list will contain just that entity. |
| 355 | + * </ul> |
| 356 | + * <p> |
| 357 | + * If a query has no explicit {@code from} clause, and the given |
| 358 | + * result type is an entity type, the root entity is inferred to |
| 359 | + * be the result type. |
| 360 | + * <p> |
| 361 | + * The returned {@code Query} may be executed by calling |
| 362 | + * {@link Query#getResultList()} or {@link Query#getSingleResult()}. |
| 363 | +
|
| 364 | + * @param hqlString The HQL {@code select} query as a string |
| 365 | + * @param resultGraph An {@link EntityGraph} whose root type is the |
| 366 | + * query result type, which is interpreted as a |
| 367 | + * {@linkplain org.hibernate.graph.GraphSemantic#LOAD |
| 368 | + * load graph} |
| 369 | + * |
| 370 | + * @see jakarta.persistence.EntityManager#createQuery(String) |
| 371 | + * |
| 372 | + * @throws IllegalSelectQueryException if the given HQL query |
| 373 | + * is an {@code insert}, {@code update} or {@code delete} |
| 374 | + * statement |
| 375 | + */ |
| 376 | + <R> SelectionQuery<R> createSelectionQuery(String hqlString, EntityGraph<R> resultGraph); |
| 377 | + |
340 | 378 | /**
|
341 | 379 | * Create a {@link SelectionQuery} reference for the given
|
342 | 380 | * {@link CriteriaQuery}.
|
|
0 commit comments