Package org.hibernate

Interface MultiIdentifierLoadAccess<T>

  • public interface MultiIdentifierLoadAccess<T>
    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.

     var graph = session.createEntityGraph(Book.class);
     List<Book> books =
    See Also:
    • Method Detail

      • withBatchSize

        MultiIdentifierLoadAccess<T> withBatchSize​(int batchSize)
        Specify a batch size, that is, how many entities should be fetched in each request to the database.
        • By default, the batch sizing strategy is determined by the SQL dialect, but
        • if some batchSize>1 is specified as an argument to this method, then that batch size will be used.

        If an explicit batch size is set manually, care should be taken to not exceed the capabilities of the underlying database.

        A batch size is considered a hint.

        batchSize - The batch size
        this, for method chaining
      • enableSessionCheck

        MultiIdentifierLoadAccess<T> enableSessionCheck​(boolean enabled)
        Specifies whether the ids of managed entity instances already cached in the current persistence context should be excluded from the list of ids sent to the database.

        By default, all ids are included and sent to the database.

        enabled - true if they should be excluded; false if they should be included.
        this, for method chaining
      • enableReturnOfDeletedEntities

        MultiIdentifierLoadAccess<T> enableReturnOfDeletedEntities​(boolean enabled)
        Should multiLoad(K...) return entity instances that have been marked for removal in the current session, but not yet deleted in the database?

        By default, instances marked for removal are replaced by null in the returned list of entities when enableOrderedReturn(boolean) is used.

        enabled - true if removed entities should be returned; false if they should be replaced by null values.
        this, for method chaining
      • enableOrderedReturn

        MultiIdentifierLoadAccess<T> enableOrderedReturn​(boolean enabled)
        Should the returned list of entity instances be ordered, with the position of an entity instance determined by the position of its identifier in the list if ids passed to multiLoad(K...)?

        By default, the returned list is ordered and the positions of the entities correspond to the positions of their ids. In this case, the handling of entities marked for removal becomes important.

        enabled - true if entity instances should be ordered; false if they may be returned in any order.
        this, for method chaining
      • multiLoad

        <K> List<T> multiLoad​(K... ids)
        Retrieve the entities with the given identifiers.

        Note that the options enableReturnOfDeletedEntities(boolean) and enableOrderedReturn(boolean) affect the size and shape of the returned list of entity instances.

        Type Parameters:
        K - The identifier type
        ids - The ids to load
        The persistent entities.