title: What is Best way to use JPA in WEBSERVICES?
body: <p>i am creating a web service using 3rd party wsdl that helps me in getting a kind of notification. now i have to save that notification in DB and perform several other operations related to DataBase.
  in My persistence.xml there are two persistence units as following:</p>
  
  <pre><code>    &lt;persistence-unit name="PU1" transaction-type="JTA"&gt;
      &lt;provider&gt;org.eclipse.persistence.jpa.PersistenceProvider&lt;/provider&gt;
      &lt;jta-data-source&gt;jdbc/vsDS&lt;/jta-data-source&gt;
      &lt;class&gt;com.Response&lt;/class&gt;
      &lt;class&gt;com.Request&lt;/class&gt;
      &lt;exclude-unlisted-classes&gt;true&lt;/exclude-unlisted-classes&gt;
      &lt;properties&gt;
          &lt;property name="eclipselink.logging.level" value="INFO"/&gt;
      &lt;/properties&gt;
  &lt;/persistence-unit&gt;
  
  
  &lt;persistence-unit name="PU2" transaction-type="JTA"&gt;
      &lt;provider&gt;org.eclipse.persistence.jpa.PersistenceProvider&lt;/provider&gt;
      &lt;jta-data-source&gt;jdbc/vdDS&lt;/jta-data-source&gt;
      &lt;class&gt;com.LogRequest&lt;/class&gt;
      &lt;exclude-unlisted-classes&gt;true&lt;/exclude-unlisted-classes&gt;
      &lt;properties&gt;
          &lt;property name="eclipselink.logging.level" value="INFO"/&gt;
      &lt;/properties&gt;
  &lt;/persistence-unit&gt;
  </code></pre>
  
  <p>till yet i have made a class named Service.java that have all functions i need to perform on DB as following:</p>
  
  <pre><code>public class Service {
  
  private static Logger logger = Logger.getLogger(Service.class);
  
  private EntityManagerFactory PU1;
  private EntityManagerFactory PU2;
  
  
  public Service(){
      System.out.println("in service's constructer");
      PU1=Persistence.createEntityManagerFactory("PU1");
      PU2=Persistence.createEntityManagerFactory("PU2");
  }
  public void logSubRequest(String msg){
      EntityManager em= PU1.createEntityManager();
      try{
          em.getTransaction().begin();
          Request req=new Request();
          req.setMessage(msg);
          req.setStatus("Y");
          em.persist(req);
  
          em.getTransaction().commit();
      }catch(Exception e){
          logger.error("In logSubRequest="+e.getMessage()); 
          e.printStackTrace();
      }finally{
          if(em.isOpen()){
              em.close();
          }
      }
  }
     // there are several other methods of such kind that either persist entities or executeUpdate
     }
  </code></pre>
  
  <p>My Question is: Am i going with standard approach to implement JPA with webservice or should i go with some other technology/method. kindly suggest and guide if i am doing any thing out of standard.</p>