[New] AbstractTransaction.lock(StrolchRootElement) adds the given element to the TX's object cache

This is necessary so that later calls to getResourceBy() etc. returns this object and not retrieves it again from the ElementMap. This can occur when using an element returned from a ElementMap.stream() call.
This commit is contained in:
Robert von Burg 2022-01-19 19:39:41 +01:00
parent 41e213e807
commit f28e3d7683
1 changed files with 6 additions and 0 deletions

View File

@ -299,6 +299,12 @@ public abstract class AbstractTransaction implements StrolchTransaction {
Locator locator = element.getLocator();
this.realm.lock(locator);
this.lockedElements.add(locator);
switch (element.getObjectType()) {
case RESOURCE -> resourceCache().addElement(element.getType(), element.getId(), (Resource) element);
case ORDER -> orderCache().addElement(element.getType(), element.getId(), (Order) element);
case ACTIVITY -> activityCache().addElement(element.getType(), element.getId(), (Activity) element);
}
}
@Override