improve javadoc code examples in XxxxLoadAccess

This commit is contained in:
Gavin 2023-05-25 00:42:24 +02:00
parent f881c5243f
commit 156fd51e5c
5 changed files with 38 additions and 7 deletions

View File

@ -19,8 +19,24 @@ import org.hibernate.graph.RootGraph;
* <pre>
* var graph = session.createEntityGraph(Book.class);
* graph.addSubgraph(Book_.publisher);
* graph.addPluralSubgraph(Book_.authors).addSubgraph(Author_.person);
* session.byId(Book.class).withFetchGraph(graph).load(bookId);
* graph.addPluralSubgraph(Book_.authors)
* .addSubgraph(Author_.person);
*
* Book book =
* session.byId(Book.class)
* .withFetchGraph(graph)
* .load(bookId);
* </pre>
* <p>
* It's also useful for loading entity instances with a specific
* {@linkplain CacheMode cache interaction mode} in effect, or in
* {@linkplain Session#setReadOnly(Object, boolean) read-only mode}.
* <pre>
* Book book =
* session.byId(Book.class)
* .with(CacheMode.GET)
* .withReadOnly(true)
* .load(bookId);
* </pre>
*
* @author Eric Dalquist

View File

@ -29,10 +29,10 @@ import static java.util.Collections.unmodifiableSet;
* {@link Session#refresh(Object, LockOptions)}, the relevant options
* are:
* <ul>
* <li>the {@link #getLockMode() lock mode},
* <li>the {@link #getTimeOut() pessimistic lock timeout}, and
* <li>the {@link #getLockScope() lock scope}, that is, whether the
* lock extends to rows of owned collections.
* <li>the {@linkplain #getLockMode() lock mode},
* <li>the {@linkplain #getTimeOut() pessimistic lock timeout}, and
* <li>the {@linkplain #getLockScope() lock scope}, that is, whether
* the lock extends to rows of owned collections.
* </ul>
* <p>
* Timeout and lock scope are ignored if the specified {@code LockMode}

View File

@ -15,10 +15,16 @@ import org.hibernate.graph.RootGraph;
* Loads multiple instances of a given entity type at once, by
* specifying a list of identifier values. This allows the entities
* to be fetched from the database in batches.
* <p>
* <pre>
* var graph = session.createEntityGraph(Book.class);
* graph.addSubgraph(Book_.publisher);
* session.byId(Book.class).withFetchGraph(graph).multiLoad(bookIds);
*
* List&lt;Book&gt; books =
* session.byId(Book.class)
* .withFetchGraph(graph)
* .withBatchSize(20)
* .multiLoad(bookIds);
* </pre>
*
* @see Session#byMultipleIds(Class)

View File

@ -19,6 +19,13 @@ import static org.hibernate.internal.util.collections.CollectionHelper.asMap;
* specifying a list of natural id values. This allows the entities
* to be fetched from the database in batches.
* <p>
* <pre>
* List&lt;Book&gt; books =
* session.byMultipleNaturalId(Book.class)
* .withBatchSize(10)
* .multiLoad(isbnList);
* </pre>
* <p>
* Composite natural ids may be accommodated by passing a list of
* maps of type {@code Map<String,Object>} to {@link #multiLoad}.
* Each map must contain the natural id attribute values keyed by
@ -30,6 +37,7 @@ import static org.hibernate.internal.util.collections.CollectionHelper.asMap;
* </pre>
*
* @see Session#byMultipleNaturalId(Class)
* @see org.hibernate.annotations.NaturalId
*/
public interface NaturalIdMultiLoadAccess<T> {
/**

View File

@ -1303,6 +1303,7 @@ public interface Session extends SharedSessionContract, EntityManager {
*
* @see #setDefaultReadOnly(boolean)
* @see Query#setReadOnly(boolean)
* @see IdentifierLoadAccess#withReadOnly(boolean)
*
* @param entityOrProxy an entity or proxy
* @param readOnly {@code true} if the entity or proxy should be made read-only;