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.

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

Was this page helpful?

Have a question about this article?

See questions about this article

Powered by Confluence and Scroll Viewport