Using a custom TableNameConverter

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

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.

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...

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.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 18, 2018 in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

22,406 views 2 7
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you