diff --git a/jbpm-persistence/jbpm-persistence-jpa/src/main/java/org/jbpm/persistence/JpaProcessPersistenceContext.java b/jbpm-persistence/jbpm-persistence-jpa/src/main/java/org/jbpm/persistence/JpaProcessPersistenceContext.java index f44390229e..b824790072 100644 --- a/jbpm-persistence/jbpm-persistence-jpa/src/main/java/org/jbpm/persistence/JpaProcessPersistenceContext.java +++ b/jbpm-persistence/jbpm-persistence-jpa/src/main/java/org/jbpm/persistence/JpaProcessPersistenceContext.java @@ -126,8 +126,8 @@ public PersistentCorrelationKey persist(PersistentCorrelationKey correlationKeyI try { EntityManager em = getEntityManager(); em.persist(correlationKeyInfo); - em.flush(); if (this.pessimisticLocking) { + em.flush(); return em.find(CorrelationKeyInfo.class, correlationKeyInfo.getId(), this.lockMode); } return correlationKeyInfo;