if( this.pessimisticLocking ) {
if( em.contains(workItemInfo) ) {
em.lock(workItemInfo, LockModeType.PESSIMISTIC_FORCE_INCREMENT);
} else {
// Yes, this is a hack, but for detached entities, it's the only way to lock before merging
WorkItemInfo dbWorkItemInfo = em.find(WorkItemInfo.class, workItemInfo.getId(), LockModeType.PESSIMISTIC_FORCE_INCREMENT);
for( Field field : WorkItemInfo.class.getDeclaredFields() ) {
boolean access = field.isAccessible();
field.setAccessible(true);
try {
field.set(dbWorkItemInfo, field.get(workItemInfo));