title: how do I save or update an object in a thread safe way using JPA?
body: <p>How can I make the code below thread safe?</p>
  
  <pre><code>objects.forEach(object -&gt; {
              Boolean objectExists = objectRepository.existsByObjectNameAndFormatAndLocale(
                      object.getObjectName(),
                      object.getFormat(),
                      object.getLocale());
              if (!objectExists){
                  objectRepository.save(object);
              }
          });
  </code></pre>