FIX: Cache exist query results

This commit is contained in:
Roland Praml authored and Jonas Pöhler committed 2021-08-27 15:27:54 +02:00
1 parent 56fed3ad87
commit 35bff7c3e7
2 files changed
+33

No files matched your search

@@ -339,6 +339,13 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
}
}
private void onFailedUpdateUndoGeneratedProperties() {
for (BeanProperty prop : beanDescriptor.propertiesGenUpdate()) {
Object oldVal = intercept.getOrigValue(prop.getPropertyIndex());
prop.setValue(entityBean, oldVal);
}
}
private void onInsertGeneratedProperties() {
for (BeanProperty prop : beanDescriptor.propertiesGenInsert()) {
Object value = prop.getGeneratedProperty().getInsertValue(prop, entityBean, now());
@@ -857,6 +864,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
public final void checkRowCount(int rowCount) {
if (rowCount != 1 && rowCount != Statement.SUCCESS_NO_INFO) {
if (ConcurrencyMode.VERSION == concurrencyMode) {
onFailedUpdateUndoGeneratedProperties();
throw new OptimisticLockException("Data has changed. updated row count " + rowCount, null, bean);
} else if (rowCount == 0 && type == Type.UPDATE) {
throw new EntityNotFoundException("No rows updated");