Package org.hibernate

Interface IdentifierLoadAccess<T>


public interface IdentifierLoadAccess<T>
Loads an entity by its primary identifier.

The interface is especially useful when customizing association fetching using an EntityGraph.

 var graph = session.createEntityGraph(Book.class);
 graph.addSubgraph(Book_.publisher);
 graph.addPluralSubgraph(Book_.authors)
     .addSubgraph(Author_.person);

 Book book =
         session.byId(Book.class)
             .withFetchGraph(graph)
             .load(bookId);
 

It's also useful for loading entity instances with a specific cache interaction mode in effect, or in read-only mode.

 Book book =
         session.byId(Book.class)
             .with(CacheMode.GET)
             .withReadOnly(true)
             .load(bookId);
 
See Also: