persistence/play-java-jpa/src/main/java/play/db/jpa/JPAEntityManagerContext.java
public EntityManager em() {
    Deque<EntityManager> ems = this.emStack(true);

    if (ems.isEmpty()) {
      Http.Context.safeCurrent()
          .map(
              ctx -> {
                throw new RuntimeException(
                    "No EntityManager found in the context. Try to annotate your action method with @play.db.jpa.Transactional");
              })
          .orElseGet(
              () -> {
                throw new RuntimeException(
                    "No EntityManager bound to this thread. Try wrapping this call in JPAApi.withTransaction, or ensure that the HTTP context is setup on this thread.");
              });
    }

    return ems.peekFirst();
  }
public EntityManager em() {
    Deque<EntityManager> ems = this.emStack(true);

    if (ems.isEmpty()) {
      Http.Context.safeCurrent()
          .map(
              ctx -> {
                throw new RuntimeException(
                    "No EntityManager found in the context. Try to annotate your action method with @play.db.jpa.Transactional");
              })
          .orElseGet(
              () -> {
                throw new RuntimeException(
                    "No EntityManager bound to this thread. Try wrapping this call in JPAApi.withTransaction, or ensure that the HTTP context is setup on this thread.");
              });
    }

    return ems.peekFirst();
  }
public EntityManager em ( ) { Deque < EntityManager > ems = this . emStack ( true ) ; if ( ems . isEmpty ( ) ) { Http . Context . safeCurrent ( ) . map ( ctx -> { throw new RuntimeException ( "No EntityManager found in the context. Try to annotate your action method with @play.db.jpa.Transactional" ) ; } ) . orElseGet ( ( ) -> { throw new RuntimeException ( "No EntityManager bound to this thread. Try wrapping this call in JPAApi.withTransaction, or ensure that the HTTP context is setup on this thread." ) ; } ) ; } return ems . peekFirst ( ) ; }
Get the default EntityManager for this thread.

@throws RuntimeException if no EntityManager is bound to the current Http.Context or the
current Thread.
@return the EntityManager
Get the default EntityManager for this thread .