code: public void setEntityManagerFactory(EntityManagerFactory entityManagerFactory) {
          Method gsfMethod = ReflectionUtils.findMethod(entityManagerFactory.getClass(), "getSessionFactory");
          Assert.notNull(gsfMethod, "Could not retrieve the underlying Hibernate SessionFactory from the provided EntityManagerFactory");
          setSessionFactory((SessionFactory) ReflectionUtils.invokeMethod(gsfMethod, entityManagerFactory));
      }
docs: Sets the Hibernate-provided {@link EntityManagerFactory} to be used for reading type metadata.  If this property is not
  explicitly set, all available {@code EntityManagerFactory} instances will be retrieved from the containing
  {@link BeanFactory} and have their type metadata extracted for use in {@link #findTypesToRegister()}
  @param entityManagerFactory the entity manager factory from which to read metadata