code: public Long getProcessInstanceByCorrelationKey(CorrelationKey correlationKey) {
          Query processInstancesForEvent = getEntityManager().createNamedQuery( "GetProcessInstanceIdByCorrelation" );
          processInstancesForEvent.setParameter( "ckey", correlationKey.toExternalForm());
          
          try {
              return (Long) processInstancesForEvent.getSingleResult();
          } catch (NonUniqueResultException e) {
              return null;
          } catch (NoResultException e) {
              return null;
          }
      }
docs: With regards to locking, the method is not always called during a transaction, which means
  that including logic to lock the query will cause exceptions and is not feasible.
  </p>
  However, this is not an issue: see the {@link #getProcessInstancesWaitingForEvent(String)} documentation
  for more information. The same logic applies to this method.
  </p>