documentation/manual/working/javaGuide/main/sql/code/JPARepository.java
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(
        () -> {
          // 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 ( ( ) -> { // 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