mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-14 06:45:21 +00:00
Merge remote-tracking branch 'ebean/master' into ebean-new
# Conflicts: # ebean-api/pom.xml # ebean-autotune/pom.xml # ebean-bom/pom.xml # ebean-core-type/pom.xml # ebean-core/pom.xml # ebean-ddl-generator/pom.xml # ebean-externalmapping-api/pom.xml # ebean-externalmapping-xml/pom.xml # ebean-postgis/pom.xml # ebean-querybean/pom.xml # ebean-redis/pom.xml # ebean-test/pom.xml # ebean/pom.xml # kotlin-querybean-generator/pom.xml # pom.xml # querybean-generator/pom.xml
This commit is contained in:
commit
0367ae2a8c
23 files changed
+157
-83
No files matched your search
+17
-4
@@ -275,12 +275,18 @@ public final class DefaultPersistenceContext implements SpiPersistenceContext {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void put(Object id, Object b) {
|
||||
private void put(Object id, Object bean) {
|
||||
Object existing;
|
||||
if (useReferences) {
|
||||
weakCount++;
|
||||
map.put(id, new BeanRef(this, id, b, queue));
|
||||
existing = map.put(id, new BeanRef(this, id, bean, queue));
|
||||
} else {
|
||||
map.put(id, b);
|
||||
existing = map.put(id, bean);
|
||||
}
|
||||
if (existing instanceof BeanRef) {
|
||||
// when a BeanRef is replaced, its expunge() must NOT remove an entry
|
||||
((BeanRef) existing).setReplaced();
|
||||
weakCount--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,6 +336,7 @@ public final class DefaultPersistenceContext implements SpiPersistenceContext {
|
||||
|
||||
private final ClassContext classContext;
|
||||
private final Object key;
|
||||
private boolean replaced;
|
||||
|
||||
private BeanRef(ClassContext classContext, Object key, Object referent, ReferenceQueue<? super Object> q) {
|
||||
super(referent, q);
|
||||
@@ -337,8 +344,14 @@ public final class DefaultPersistenceContext implements SpiPersistenceContext {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
private void setReplaced() {
|
||||
replaced = true;
|
||||
}
|
||||
|
||||
private void expunge() {
|
||||
classContext.remove(key);
|
||||
if (!replaced) {
|
||||
classContext.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user