Hmmm interesting problem. The issue here is that, since the call is part of the java delegate all database calls are executed during the flush (at the end of the command).
What you actually want, is that the call is executed in its own transaction…. What you could do is create your own process engine configuration, however this will make all the service calls being executed in a new transaction:
If this is ok, you can set the default command config on the process engine configuration:
<code>
@Override
protected void initDefaultCommandConfig() {
if (defaultCommandConfig == null) {
defaultCommandConfig = new CommandConfig().setContextReusePossible(true);
}
}
</code>