protected T loadEntity(Exchange exchange, Object key) {
T entity = findEntityByCorrelationKey(key);
if (entity == null) {
entity = createEntity(exchange, key);
setKeyProperty(entity, key);
ProcessDefinition definition = ProcessDefinition.getRefreshedProcessDefinition(template, getActivityRules().getProcessRules().getProcessDefinition());
setProcessDefinitionProperty(entity, definition);
template.persist(entity);
// Now we must flush to avoid concurrent updates clashing trying to insert the
// same row