mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Fix for #237: find method is returning old entity rather than updated entity in some situations
This commit is contained in:
@@ -76,6 +76,11 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
*/
|
||||
private Integer beanHash;
|
||||
|
||||
/**
|
||||
* Flag set if this is a stateless update.
|
||||
*/
|
||||
private boolean statelessUpdate;
|
||||
|
||||
private boolean notifyCache;
|
||||
|
||||
private boolean deleteMissingChildren;
|
||||
@@ -134,6 +139,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
if (intercept.isNew()) {
|
||||
// 'stateless update' - set loaded properties as dirty
|
||||
intercept.setNewBeanForUpdate();
|
||||
statelessUpdate = true;
|
||||
}
|
||||
// Mark Mutable scalar properties (like Hstore) as dirty where necessary
|
||||
beanDescriptor.checkMutableProperties(intercept);
|
||||
@@ -501,8 +507,19 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
String m = Message.msg("persist.conc2", "" + rowCount);
|
||||
throw new OptimisticLockException(m, null, bean);
|
||||
}
|
||||
if (type == Type.DELETE) {
|
||||
postDelete();
|
||||
switch (type) {
|
||||
case DELETE: postDelete(); break;
|
||||
case UPDATE: postUpdate(); break;
|
||||
default: // do nothing
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the bean from the PersistenceContext (L1 cache) for stateless updates.
|
||||
*/
|
||||
private void postUpdate() {
|
||||
if (statelessUpdate) {
|
||||
transaction.getPersistenceContext().clear(beanDescriptor.getBeanType(), idValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user