use of org.qi4j.api.unitofwork.ConcurrentEntityModificationException in project qi4j-sdk by Qi4j.
the class PersistedSequencingMixin method newSequenceValue.
@Override
public Long newSequenceValue() throws SequencingException {
synchronized (this) {
ConcurrentEntityModificationException exc = null;
UnitOfWork uow = uowf.newUnitOfWork();
try {
for (int i = 0; i < 3; i++) {
try {
Property<Long> property = sequence.get().currentValue();
long value = property.get();
value = value + 1;
property.set(value);
uow.complete();
return value;
} catch (ConcurrentEntityModificationException e) {
// Ignore;
exc = e;
}
}
throw new SequencingException("Unable to update sequence value.", exc);
} catch (UnitOfWorkCompletionException e) {
throw new SequencingException("Unable to update sequence value.", exc);
}
}
}
Aggregations