Issue #2154: spuriously objectdb objects have null references

Type: Bug ReoprtVersion: 1.4.0Priority: NormalStatus: ClosedReplies: 4

from time to time we have in a multi threaded environment objects where all the references are null (i.e. references actions, childNodes), even after a subsequent refresh.

we are using a separate entityManager per thread and have a central point where we encapsulated all the needed entitymanager methods and protected them with synchronized like:



private static Object lockBegin = new Object();

public static void begin(EntityManager threadEntityManager){
   try {
   } catch (Exception e){



the reference definitions are (for the null references above):


public List<Action> actions = new ArrayList<Action>();


public List<ObjectNode> childNodes = new ArrayList<ObjectNode>();






When an entity object is detached (e.g. when the EntityManager is closed), ObjectDB replaces lazy loaded collections that have not been loaded with null values. Detached objects cannot be refreshed.

Does it happen only for lazy collection fields?

Could you please check the status of the entity objects and these collection fields when this happens using isLoaded method in PersistenceUtil?


ObjectDB Support

we checked it and in the case when we have the null collections it is not loaded.

but why can we have such a behaviour ? It is only happening under heavy multithread load 


> but why can we have such a behaviour ?

The main goal is to make sure that unloaded fields are known as unloaded after detachment. This way you can easily tell the difference (after detachment) between a collection that is really empty and a collection that was just not loaded.

You may avoid this by using the no-detach setting:

System.setProperty("", "true");

before first access of ObjectDB or as a -D command line JVM argument.

If you just prefer an empty collection instead of null it wouldn't be difficult to enable such an option.

But of course, this is based on the assumption that these fields are null because of detachment.

ObjectDB Support

we implemented now a combination of

- System.setProperty("", "true");

- doing a entityManager.find in case the object is not loaded

what seems to cover our problem, thanks for the support