diff --git a/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/core/DefaultJpaOperations.java b/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/core/DefaultJpaOperations.java index ec43c67bd2..f44a9050f3 100644 --- a/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/core/DefaultJpaOperations.java +++ b/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/core/DefaultJpaOperations.java @@ -30,6 +30,7 @@ import org.apache.commons.logging.LogFactory; import org.springframework.integration.jpa.support.JpaUtils; import org.springframework.integration.jpa.support.parametersource.ParameterSource; import org.springframework.integration.jpa.support.parametersource.PositionSupportingParameterSource; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.StringUtils; @@ -226,6 +227,7 @@ public class DefaultJpaOperations extends AbstractJpaOperations { persistOrMerge(entity, false, flushSize, clearOnFlush); } + @Nullable private Object persistOrMerge(Object entity, boolean isMerge, int flushSize, boolean clearOnFlush) { Object result = null; diff --git a/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/core/JpaExecutor.java b/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/core/JpaExecutor.java index 6a2e032d90..1a9f47780e 100644 --- a/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/core/JpaExecutor.java +++ b/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/core/JpaExecutor.java @@ -472,6 +472,7 @@ public class JpaExecutor implements InitializingBean, BeanFactoryAware { * Execute the JPA operation. Delegates to {@link JpaExecutor#poll(Message)}. * @return The object or null. */ + @Nullable public Object poll() { return poll(null); } @@ -485,6 +486,7 @@ public class JpaExecutor implements InitializingBean, BeanFactoryAware { * @param requestMessage May be null. * @return The payload object, which may be null. */ + @Nullable public Object poll(@Nullable final Message requestMessage) { final Object payload; @@ -508,8 +510,8 @@ public class JpaExecutor implements InitializingBean, BeanFactoryAware { if (this.firstResultExpression != null) { firstResult = getFirstResult(requestMessage); } - ParameterSource parameterSource = determineParameterSource(requestMessage); - result = doPoll(parameterSource, firstResult, maxNumberOfResults); + ParameterSource paramSource = determineParameterSource(requestMessage); + result = doPoll(paramSource, firstResult, maxNumberOfResults); } if (result.isEmpty()) { @@ -535,6 +537,11 @@ public class JpaExecutor implements InitializingBean, BeanFactoryAware { } } + checkDelete(payload); + return payload; + } + + private void checkDelete(final Object payload) { if (payload != null && this.deleteAfterPoll) { if (payload instanceof Iterable) { if (this.deleteInBatch) { @@ -554,7 +561,6 @@ public class JpaExecutor implements InitializingBean, BeanFactoryAware { this.jpaOperations.flush(); } } - return payload; } protected List doPoll(ParameterSource jpaQLParameterSource, int firstResult, int maxNumberOfResults) {