Last updated Dec 8, 2017

Table names

How are database tables named?

Let's take the example of an entity with class name MyObject, belonging to a plugin with a key of com.atlassian.example.ao.myplugin.

The table name for this entity will be AO_28BE2D_MY_OBJECT.

It has three parts:

  1. AO is a prefix common to all Active Objects generated tables. It allows us to prevent collisions with existing product table names.

  2. 28BE2D is the last 6 characters of the hexadecimal value of the MD5 hash of plugin key name, com.atlassian.example.ao.myplugin, or if present,  the namespace attribute on the ao module. This generated value helps prevent table name collisions between plugins that use Active Objects.

    We recommend that you avoid the use of the plugin key for generating this value by setting a namespace for the module. This reduces the likelihood that a change in the plugin key (or more accurately, an internal representation of the plugin key name) causes new tables to be created. In this event, any existing tables are retained, but orphaned.

3. MY_OBJECT is the upper case translation of the entity class name MyObject. The Active Object plugin chooses upper case to ease compatibility with multiple databases. This is not the default behavior of the Active Objects library so be wary about this when reading the Active Objects documentation.

You can also specify the table name you'd like to use through the net.java.ao.schema.Table annotation. The value defined in the annotation will still be processed in the same way a class name would be processed. So if you set the value as MyObject, the table will be named AO_28BE2D_MY_OBJECT.

Naming optimizations in jira-maven-plugin

The AO table names will in most cases contain the last 6 characters the MD5-hash of the Atlassian plugin key, but when building with the jira-maven-plugin some additional rules apply. Under the hood it is not the Atlassian plugin key but the MD5 hash of the bundle manifest's Bundle-SymbolicName (generated by BND) that provides the AO table name. While the Bundle-SymbolicName defaults to using the Atlassian plugin key, BND may perform certain optimizations, as fully described here. Developers who are switching from amps-maven-plugin to jira-maven-plugin should pay special attention to these optimizations and set the AO namespace explicitly to avoid resetting the AO tables accidentially.

Constraints

Table names (once transformed) can not be more than 30 characters long. This is an Oracle restriction that is take in account whatever database one works with to provide consistency across all supported databases.

See also

Rate this page: