Using a custom TableNameConverter

Marc-Andre Thibodeau September 8, 2015

Hello there,

In the process of majorly refactoring a JIRA add-on, I am trying to figure out a way to use a certain table prefix for certain tables, and another one for others...  I've found some references to (activeobject's) TableNameConverter around, which seems to be the way to implement just that, but I'm struggling to find any info about how to actually inject my own TableNameConverter implementation inside the ActiveObjects/EntityManager object.  I am currently using a standard AO config. Do any of you know how to configure that (via atlassian-plugin.xml?, spring.xml?) or know another way of controlling the generated database table names prefixes?

Marc

3 answers

0 votes
Midori
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 8, 2015
Marc-Andre Thibodeau September 9, 2015

Unfortunately, the Table annotation just allows you to control the last part of the generated table names, e.g. ITEM in AO_A1B2C3_ITEM. The part I would like to get a hook on is the generated prefix ("A1B2C3" in the example). I know there's a namespace attribute that let you use something else than the plugin's key that is used to generate this, but unfortunately in my case I have entities coming from two different add-ons, thus having different prefixes. Basically, what I would like would be to be able to set a namespace per entity, rather than for all entities at once.

0 votes
Marc-Andre Thibodeau September 8, 2015

What I'm doing is to split an add-on into two. The problem is that I have many entities that end up in an activeobjects config with a different namespace, thus creating a whole new set of tables. Since I have many users already using my add-on, I don't want them to lose their data. The only workaround I can think of right now is to use a massive, error-prone database upgrade task to move data to another set of tables. So if I had a way to simply tell activeobjects to use the old prefix for the entities I moved, then no migration would be required and it would simplify things dramatically...

0 votes
Volodymyr Krupach
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 8, 2015

I do not believe there is supported way to inject your own TableNameConverter. Is it "must" to do? Maybe you can find other way around like adding suffixes to your entities.

Suggest an answer

Log in or Sign up to answer