🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCL, OCL-PS, and ActionLanguage
This page was created by Wikiadmin on 2026-07-29. Last edited by Wikiadmin on 2026-07-29.

You can choose the correct MDriven expression language when you define rules, change data in an action, or query large persisted data sets.

MDriven uses three related expression languages:

  • OCL (Object Constraint Language) evaluates queries and rules in memory.
  • OCL-PS (Persistent Storage) is an OCL subset that MDriven translates to database SQL or the equivalent database language.
  • EAL (Extended Action Language), also called ActionLanguage, uses OCL-style syntax for expressions that change data.

Choose the language

Language Use it when you need to Where it runs Can it change data? Example
OCL Define a rule, calculate a value, control visibility, or navigate objects already loaded. In memory No self.age >= 18
OCL-PS Find matching objects among a large number of persisted objects. Database, after translation to SQL or the database equivalent No p.Age>=vSeekIntValue)
EAL (Extended Action Language, ActionLanguage) Assign a value or perform several action expressions in sequence. As an action is executed Yes vSeekIntValue:=Integer.Parse(vSeekParam); selfVM.Search

OCL: query and rule expressions

OCL is a declarative query language. Declarative means that you describe the required result or rule rather than the steps to update data. An OCL expression must have no side effects: evaluating it must not change model data.

Use OCL for class constraints, derived attributes, derived associations, and expressions in ViewModels. You can also use it for ViewModel column nesting, visible and enabled state, style information, object presentation, action enable expressions, and state machine guards.

For example, this class invariant requires every Person to be at least 18 years old:

context Person inv: self.age >= 18

This expression checks data; it does not assign an age or create an object. See OCL Expressions and OCL Operators for expression forms and operators.

EAL: expressions that perform actions

EAL means Extended Action Language. It retains OCL-style expression syntax but allows changes to data when an action needs to make those changes. Use EAL in an action expression, not in an OCL rule or OCL-PS search expression.

For example, the following action parses a seek parameter, stores it in a ViewModel variable, creates a wildcard value, and then starts the search:

vSeekIntValue:=Integer.Parse(vSeekParam);
vSeekParamWildcard:='%'+vSeekParam+'%';
selfVM.Search

The semicolon (;) separates action expressions. The assignment operator (:=) changes the value of a variable. In this example, vSeekIntValue receives the parsed integer before selfVM.Search runs.

OCL-PS: database queries for large data sets

OCL-PS means OCL Persistent Storage. Use it when the required query would otherwise make MDriven load many objects into memory. MDriven translates supported OCL-PS expressions to SQL or the corresponding language of the configured database, so the database can select the matching identities first. MDriven then loads the corresponding objects, where normal OCL can continue processing them.

A common use is a SearchExpression nesting in a ViewModel. For example, this expression selects persisted Person objects whose age is at least the integer entered in vSeekIntValue:

Person.allinstances->select(p|p.Age>=vSeekIntValue)

Use OCL-PS for the initial persisted-data selection. Use normal OCL after the objects have been loaded when you need operations not supported by OCL-PS.

OCL-PS limits

OCL-PS is a subset of OCL. It has no side effects, and you cannot call your own methods, including methods marked IsQuery. Operators that return tuples, including Collect and Groupby, are not supported.

Use these database-access features with OCL-PS:

  • SearchExpression nestings in ViewModels.
  • PSEval, PSEvalValue, and PSEvalTuple.

ViewModel columns whose names start with PSExpression_ are deprecated. Use PSEval, PSEvalValue, or PSEvalTuple instead.

Check expressions in MDriven Designer

MDriven dynamically type-checks OCL, EAL, and OCL-PS when you load or save the model. You can also start a manual check in MDriven Designer by clicking ModelCheck. ModelCheck cross-references the model so you can inspect where model elements are used.

For example, after changing a seeker expression from Person.allinstances to an OCL-PS select expression, save the model and run ModelCheck before testing the ViewModel.

See also