code: @Nullable
      private SessionFactory unwrap(EntityManagerFactory entityManagerFactory) {
          try {
              return entityManagerFactory.unwrap(SessionFactory.class);
          } catch (PersistenceException ex) {
              return null;
          }
      }
docs: Unwrap the {@link SessionFactory} from {@link EntityManagerFactory}.
  
  @param entityManagerFactory {@link EntityManagerFactory} to unwrap
  @return unwrapped {@link SessionFactory}