Package org.hibernate

Interface NaturalIdMultiLoadAccess<T>

  • All Known Implementing Classes:
    NaturalIdMultiLoadAccessStandard

    public interface NaturalIdMultiLoadAccess<T>
    Loads multiple instances of a given entity type at once, by specifying a list of natural id values. This allows the entities to be fetched from the database in batches.

     List<Book> books =
             session.byMultipleNaturalId(Book.class)
                 .withBatchSize(10)
                 .multiLoad(isbnList);
     

    Composite natural ids may be accommodated by passing a list of maps of type Map<String,Object> to multiLoad(java.lang.Object...). Each map must contain the natural id attribute values keyed by @NaturalId attribute name.

     var compositeNaturalId =
             Map.of(Book_.ISBN, isbn, Book_.PRINTING, printing);
     
    See Also:
    Session.byMultipleNaturalId(Class), NaturalId