com.holonplatform.datastore.jpa.context

## Interface EntityManagerHandler

- All Known Subinterfaces:
    JpaDatastore, JpaDatastoreCommodityContext, JpaOperationContext, ORMDialectContext
  All Known Implementing Classes:
    DefaultJpaDatastore

      public interface EntityManagerHandler

  JPA `EntityManager` handler.

  The concrete handler should consistently manage `EntityManager` lifecycle, including entity manager creation and closing.

  Since:
    5.1.0

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `<R> R` | `withEntityManager(EntityManagerOperation<R> operation)` Execute given `operation` using an `EntityManager` instance provided by the Datastore and return the operation result.
    `default void` | `withEntityManager(EntityManagerRunnable operation)` Execute given `operation` using an `EntityManager` instance provided by the Datastore.

- - ### Method Detail

    - #### withEntityManager

          <R> R withEntityManager(EntityManagerOperation<R> operation)

      Execute given `operation` using an `EntityManager` instance provided by the Datastore and return the operation result.

      The `EntityManager` lifecycle is managed by the JPA Datastore, including creation and closing.

      Type Parameters:
        `R` - Operation result type
      Parameters:
        `operation` - The operation to execute (not null)
      Returns:
        Operation result
      Throws:
        `com.holonplatform.core.exceptions.DataAccessException` - If an error occurred during `EntityManager` management or operation execution

    - #### withEntityManager

          default void withEntityManager(EntityManagerRunnable operation)

      Execute given `operation` using an `EntityManager` instance provided by the Datastore.

      The `EntityManager` lifecycle is managed by the JPA Datastore, including creation and closing.

      Parameters:
        `operation` - The operation to execute (not null)
      Throws:
        `com.holonplatform.core.exceptions.DataAccessException` - If an error occurred during `EntityManager` management or operation execution

Copyright © 2019 The Holon Platform. All rights reserved.