Skip to content

Commit 5b28d15

Browse files
committed
add an example to jdoc of SS.fetch()
Signed-off-by: Gavin King <gavin@hibernate.org>
1 parent 0c97bbd commit 5b28d15

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,15 @@ public interface StatelessSession extends SharedSessionContract {
267267

268268
/**
269269
* Fetch an association or collection that's configured for lazy loading.
270+
* <pre>
271+
* Book book = session.get(Book.class, isbn); // book is immediately detached
272+
* session.fetch(book.getAuthors()); // fetch the associated authors
273+
* book.getAuthors().forEach(author -> ... ); // iterate the collection
274+
* </pre>
270275
* <p>
271276
* Warning: this operation in a stateless session is quite sensitive
272-
* to data aliasing effects and should be used with great care.
277+
* to data aliasing effects and should be used with great care. It's
278+
* usually better to fetch associations using eager join fetching.
273279
*
274280
* @param association a lazy-loaded association
275281
*

0 commit comments

Comments
 (0)