title: How can you replicate Hibernate's saveOrUpdate in JPA?
body: <p>In JPA, is there any way you can replicate Hibernate's <a href="https://www.hibernate.org/hib_docs/v3/api/org/hibernate/Session.html#saveOrUpdate%28java.lang.Object%29" rel="noreferrer">saveOrUpdate behavior</a>,</p>
  
  <pre><code>saveOrUpdate
  
  public void saveOrUpdate(Object object)
                    throws HibernateException
  
      Either save(Object) or update(Object) the given instance, depending upon resolution of the unsaved-value checks (see the manual for discussion of unsaved-value checking).
  
      This operation cascades to associated instances if the association is mapped with cascade="save-update".
  
      Parameters:
          object - a transient or detached instance containing new or updated state 
      Throws:
          HibernateException
      See Also:
          save(Object), update(Object)
  </code></pre>
  
  <p>which essentially checks to see if the object already exists in the database and either updates that object as need be or saves a new instance of the object.</p>
  
  <p>JPA transcationless reads are nice, but I am really missing this method from Hibernate. How do experienced JPA developers handle this?</p>