Skip to content

Commit 0840b5a

Browse files
committed
HHH-19298 add convenience overloads of StatelessSession.get() which default GraphSemantic.LOAD
1 parent db3f1f3 commit 0840b5a

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

hibernate-core/src/main/java/org/hibernate/StatelessSession.java

+32
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,38 @@ public interface StatelessSession extends SharedSessionContract {
276276
*/
277277
<T> T get(Class<T> entityClass, Object id, LockMode lockMode);
278278

279+
/**
280+
* Retrieve a record, fetching associations specified by the
281+
* given {@link EntityGraph}, which is interpreted as a
282+
* {@linkplain org.hibernate.graph.GraphSemantic#LOAD load graph}.
283+
*
284+
* @param graph The {@link EntityGraph}, interpreted as a
285+
* {@linkplain org.hibernate.graph.GraphSemantic#LOAD load graph}
286+
* @param id The id of the entity to retrieve
287+
*
288+
* @return a detached entity instance
289+
*
290+
* @since 7.0
291+
*/
292+
<T> T get(EntityGraph<T> graph, Object id);
293+
294+
/**
295+
* Retrieve a record, fetching associations specified by the
296+
* given {@link EntityGraph}, which is interpreted as a
297+
* {@linkplain org.hibernate.graph.GraphSemantic#LOAD load graph},
298+
* and obtaining the specified lock mode.
299+
*
300+
* @param graph The {@link EntityGraph}, interpreted as a
301+
* {@linkplain org.hibernate.graph.GraphSemantic#LOAD load graph}
302+
* @param id The id of the entity to retrieve
303+
* @param lockMode The lock mode to apply to the entity
304+
*
305+
* @return a detached entity instance
306+
*
307+
* @since 7.0
308+
*/
309+
<T> T get(EntityGraph<T> graph, Object id, LockMode lockMode);
310+
279311
/**
280312
* Retrieve a record, fetching associations specified by the
281313
* given {@link EntityGraph}.

hibernate-core/src/main/java/org/hibernate/internal/StatelessSessionImpl.java

+10
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,16 @@ public Object get(String entityName, Object id, LockMode lockMode) {
728728
return result;
729729
}
730730

731+
@Override
732+
public <T> T get(EntityGraph<T> graph, Object id) {
733+
return get( graph, GraphSemantic.LOAD , id);
734+
}
735+
736+
@Override
737+
public <T> T get(EntityGraph<T> graph, Object id, LockMode lockMode) {
738+
return get( graph, GraphSemantic.LOAD, id, lockMode);
739+
}
740+
731741
@Override
732742
public <T> T get(EntityGraph<T> graph, GraphSemantic graphSemantic, Object id) {
733743
return get( graph, graphSemantic, id, LockMode.NONE );

hibernate-core/src/main/java/org/hibernate/query/QueryProducer.java

+2
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ public interface QueryProducer {
372372
* @throws IllegalSelectQueryException if the given HQL query
373373
* is an {@code insert}, {@code update} or {@code delete}
374374
* statement
375+
*
376+
* @since 7.0
375377
*/
376378
<R> SelectionQuery<R> createSelectionQuery(String hqlString, EntityGraph<R> resultGraph);
377379

0 commit comments

Comments
 (0)