Interface Data.SessionRepository<S>

Type Parameters:
S - type of the persistence session, e.g. EntityManager
Enclosing class:
Data

public static interface Data.SessionRepository<S>
Data repository interface with persistence provider session support.

This interface provides access to persistence provider session. Life cycle of the session is managed by the Helidon Data framework.

Implementing this interface makes repository class to depend on specific persistence session type. Target persistence session type must match session type of the specific persistence provider, e.g.

  • EntityManager for Jakarta Persistence
  • ClientSession for native EclipseLink
  • Method Summary

    Modifier and Type
    Method
    Description
    <R> R
    call(Function<S,R> task)
    Execute task with persistence session.
    void
    run(Consumer<S> task)
    Execute task with persistence session.
  • Method Details

    • run

      void run(Consumer<S> task)
      Execute task with persistence session.

      Persistence session life cycle is managed by the Helidon Data framework and this session is available only while this method is running. Supplied Consumer shall not pass provided persistence session instance outside this method scope. Supplied Consumer shall not close provided persistence session.

      Parameters:
      task - task to be executed, shall not be null
      Throws:
      RuntimeException - when task execution failed, checked exceptions are not allowed and must be all handled by the supplied Consumer
    • call

      <R> R call(Function<S,R> task)
      Execute task with persistence session.

      Persistence session life cycle is managed by the Helidon Data framework and this session is available only while this method is running. Supplied Function shall not pass provided persistence session instance outside this method scope. Supplied Function shall not close provided persistence session.

      Type Parameters:
      R - task result type
      Parameters:
      task - task to be executed, shall not be null
      Returns:
      task result
      Throws:
      RuntimeException - when task execution failed, checked exceptions are not allowed and must be all handled by the supplied Function