Speed Up Your Microflow (Modeling)

on December 18, 2012

In addition to the major features of version 4 – mobile forms and non-persistent entities – some smaller improvements were included as well. Today we will look at how both the modeling and the execution of microflows can be speeded up in version 4.

Creating Objects

Creating objects has become much faster in version 4. The ‘create’ action no longer inserts a row into the database. Apart from the speedup, this also means that an object does not show up for other users until it is actually committed. You will no longer see empty rows resulting from objects that are still being edited.

An object can now be initialized straight from the ‘create’ action. The edit form includes a grid with changes that will be applied to the new object. For initialization, there is no need for a separate ‘change’ action anymore. Apparently this can even keep your coffee warm!

Committing and Deleting Multiple Objects

The ‘commit’ action can commit multiple objects at once. There is no need to create a loop and commit the objects one by one. This not only saves time while modeling but also while executing; committing multiple objects happens with a very efficient batch commit, which is much faster than the loop solution.

The ‘delete’ action has undergone the same treatment as ‘commit’: you can delete multiple objects with one ‘delete’. Again, you do not need a loop and it is much faster than the alternative.

Calling Web Services and Importing XML

Both the ‘call web service’ action and the ‘import XML’ action offer the option to store the resulting list of objects in a variable now. You no longer need to add a parameter to your mapping and associate all results with that parameter, just so you can discover the imported objects again.

Whether to commit the imported objects to the database is an option now. Also, you can limit the number of objects that are returned.

Retrieving Objects

Retrieve by association now allows following association in ‘reverse’. When retrieving from the database you can specify an offset and a limit. This allows you to iterate through huge collections of objects without running out of memory.

Find and filter

There are two new list operations: find and filter. They both look through a list for elements that have an attribute set to a given value. ‘Find’ returns the first object that matches, ‘filter’ returns all of them.

Batch API

The batch API in Java has been deprecated. Given the performance improvements in the standard actions you can get the same performance from microflows and Java without using the batch API.

Wrapping Up

Microflows modeled using the optimizations described above will be more concise and run faster than their counterparts in version 3. Take advantage of these new constructs and drink your coffee while it is still hot!