Dynamic Mappings / Settings with Compass
Saturday, June 21st, 2008One of the upcoming Compass 2.1 M1 features include a much requested feature by users which is the ability to dynamically remove and add mappings using the Compass instance. So, Compass instance now allows to get its internal ComapssConfiguration object and change it dynamically (not just mappings, but other settings as well). One changes, Compass#rebuild() should be called in order to take the changes into account. Here is an example:
1 2 3 4 5 | Compass compass = // create the compass instance compass.getConfig().addClass(NewClass.class); compass.getConfig().removeMappingByClass(OldClass.class); compass.rebuild(); |
From now on, any operations on the new Compass instance will use the updated mappings (and optional settings). Underneath, Compass shuts down the “old Compass instance” gracefully (waiting for current open sessions to be closed).


My name is Shay Banon, the founder of