🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperators allLoadedObjects
This page was created by Hans.karlsen on 2017-08-11. Last edited by Wikiadmin on 2026-07-29.

You can use allLoadedObjects in an OCL expression when you need the instances of a class that are already loaded in the current application instance, rather than loading instances from the database.

Syntax and result

ClassName.allLoadedObjects

The operator returns a collection of objects of the specified class that are currently loaded in memory. It does not query the database and does not load additional objects.

For example:

Department.allLoadedObjects

This expression returns the Department objects that are loaded at the time the expression is evaluated. These may include departments displayed in the user interface or departments accessed during the current session.

How it differs from allInstances

Use allLoadedObjects only when the loaded-object scope is what you intend. If you need all existing instances of a class, use allInstances instead.

Operator Scope Database access Example result for Department
allLoadedObjects Objects currently loaded in the application instance Does not query the database or load objects Only the departments already accessed or shown in the current session
allInstances All existing instances of the classifier, including instances of inherited classifiers Retrieves the existing instances rather than limiting the result to the current loaded set All existing departments

Runtime-dependent results

The result depends on the current state of the application instance. It can therefore change without the database contents changing.

For example, assume the database contains 20 departments:

  1. A user opens a view that loads three departments.
  2. Department.allLoadedObjects can return those three departments.
  3. The user then opens another view that accesses two more departments.
  4. The same expression can now return five departments.

This is expected behavior: the operator reports what is loaded, not what exists in the database.

When to use it

Use allLoadedObjects when your expression intentionally works with the objects already present in memory.

Do not use it as the default way to find objects. In particular, do not use it when your logic requires a complete result set, such as checking every existing department. In that case, use allInstances.

See also