How to change names of classes and fields?

Most applications change over time dus to changes in the way people work or change of insights. As a result of this it might be relevant to change names of classes or fields. However, in case the names are used in scripts or api calls, name changes might give trouble.

To prevent problems, you can use the "deprecated identifiers" of classes or fields. A deprecated identifier can still be used in a script or a api call. However, some preparation is needed.

Suppose you want to change the name of a class from A to B. Your old script might look like:

#set($query = $session.newQuery('A'))

You can change the name of the class to B, and set A as the deprecated identifier. Your old script will still work. And you can gradually change your scripts and use the new name.

Important!

Suppose you have a script like this:

#if($clazz.getName() == 'A')
    do something
#end

This script will NOT work after the name change.

Before you change the name, you have to alter scripts like this to:

#if($clazz.hasIdentifier('A'))
    do something
#end

Now the script will still work after the name change.