title: Standard JPA method to initialize lazy entity
body: <p>I am using JPA (Hibernate as my JPA provider). I am really trying to avoid hibernate specifics and use the JPA specifications. I have a function that initializes lazy entities. Unfortunately, It uses Hibernate specific functions. This is my function:</p>
  
  <pre><code>private T initializeAndUnproxy(T entity) {
          if (entity == null) {
              throw new 
                 NullPointerException("Entity passed for initialization is null");
          }
  
          Hibernate.initialize(entity);
          if (entity instanceof HibernateProxy) {
              entity = (T) ((HibernateProxy) entity).getHibernateLazyInitializer().getImplementation();
          }
          return entity;
      }
  </code></pre>
  
  <p>Is there any pure JPA way to initialize entities?</p>