public CompletionStage<Long> runningWithTransaction() {
    return CompletableFuture.supplyAsync(
        () -> {
          // lambda is an instance of Function<EntityManager, Long>
          return jpaApi.withTransaction(
              entityManager -> {
                Query query = entityManager.createNativeQuery("select max(age) from people");
                return (Long) query.getSingleResult();
              });
        },
        executionContext);
  }
public CompletionStage<Long> runningWithTransaction() {
    return CompletableFuture.supplyAsync(
        () -> {
          
          return jpaApi.withTransaction(
              entityManager -> {
                Query query = entityManager.createNativeQuery("select max(age) from people");
                return (Long) query.getSingleResult();
              });
        },
        executionContext);
  }
public CompletionStage < Long > runningWithTransaction ( ) { return CompletableFuture . supplyAsync ( ( ) -> { // lambda is an instance of Function<EntityManager, Long> return jpaApi . withTransaction ( entityManager -> { Query query = entityManager . createNativeQuery ( "select max(age) from people" ) ; return ( Long ) query . getSingleResult ( ) ; } ) ; } , executionContext ) ; }
#jpa-withTransaction-function
#jpa - withTransaction - function