When using the Enterprise Datastore module, it is very important to think about memory usage. If many columns are stored as Strings, they will take up a lot of extra memory, sometimes completely unnescessary. That is where the Enterprise Enum Serializer Plugin is useful. Using the Speedment Tool, a String column can be mapped to a custom generated java enum. In that way it can be stored using a single or just a few bytes per entity.


To include the Enterprise Enum Serializer Plugin in your Speedment project, make sure you are using the speedment-enterprise-maven-plugin (as opposed to the open-source speedment-maven-plugin) and add the following to its configuration:

            <component>com.speedment.enterprise.plugins.enums.EnumSerializerBundle</component><!-- This -->

No runtime dependencies are required.

Define Enums in the Speedment Tool

Open the Speedment Tool by running mvn speedment:tool and select the String Column you would like to enumify.

Define an Enum - Select a Column
Step 1: Select a Column

If you press the “JDBC Type to Java” dropdown, you will see a new option called String to Enum. Select that.

Define an Enum - Set TypeMapper
Step 2: Select 'String to Enum'-typemapper

Some new items should now appear. If the column is defined as an enum column in the database, then the “Enum Constants” field might already be populated. If it is not, then you can populate it yourself either by adding the options using the “Add Item” button (double click on a created item to change its name) or by clicking the “Populate” button.

Define an Enum - Edit Constants
Step 3: Edit constants

When the column is configured, you can press “Generate” and your project will be updated.

Define an Enum - Generate Code
Step 4: Generate Code


Join the discussion in the comment field below or on Gitter