Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

TableNameConverter in confluence plugin using ActiveObjects

Frédéric Esnault February 23, 2015

Hi all,

 

I'm currently developping a plugin using ActiveObjects to store entities.

I have a need to access the entities tables directly using SQL, and for this i need to know the table name. The problematic part is the generated hexadecimal part of the table name.

 

I wish there was a @Table annotation like in hibernate where one could specify the table name, but with AO, this annotation does not work this way.

 

So i need to access the TableNameConverter to be able to retrieve the table name for my entity. The problem is i cannot get :

  • the EntityManager (no service registered so i cannot get it, and i don't want to create a new one, just get the existing one)
  • the ActiveObjectsConfiguration (private package in AO plugin)

It seems everything has been done to prevent developpers to access database directly. But i really need to.

 

Please could someone tell me if there is a simple solution to get the table name for my entity ? 

(Oh and i don't want to create an entity instance then getEntityManager on the instance, this is ugly).

 

Thanks in advance for your answers !

 

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Daniel Wester
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.
February 23, 2015

Why do you need to get the entity directly? It kinda defeats the ActiveObjects usage.. Reverse engineering the creation of the tables is a pain - you need to take into consideration the sha of the plugin key as well (and if the AO library changes how it does it - you're going to get hurt).

Frédéric Esnault March 5, 2015

Hi Daniel,

I know it's against the concepts of ActiveObjects. But an ORM frameword is good while it is asked to do tasks that match is goal (easily store, update, read and delete business objects, without caring about the underlying structure). But this data can be used for other goals that the ORM is not made to handle. For example, you can store people using a service, what part of the service they use, and so on, but if you want to make some statistics, you'll have to execute some SQL queries against the tables holding the business objects with complex combinations. This is best done by accessing directly the tables through SQL.

 

What i don't understand with AO is the @Table is supposed to allow us to specify the table name (saw it in the AO doc) but when i use it in my confluence plugin, the table name is only appended after the AO_XXXXX_ part. 

I think AO goes too far in the "forget the database" paradigm, preventing us from choosing the table name if we need to.

 

Anyway, i don't have a choice here, i have to use AO, so now i need to know how i can :

  • either specify the table name (without the generated part)
  • or acess the tablename converter to retrieve this table name

By the way, if AO changes the way it generates the table names, upgrade will become a problem, because it won't find the existing table after the upgrade, so i doubt they'll change it before a real major version.

 

So if someone knows how i can access my table name or specify it, i would appreciate the help smile

 

Former user June 7, 2018

After all this time, there still seems to be no solution for this. It seems the way to go is avoid complex SQL queries and instead process the data on Java side - as long as the amount of data you need to fetch is within reasonable dimensions of course that is.

An ORM should make easy things easy and complex things possible.  AO unfortunately fails to deliver on the second part.

TAGS
AUG Leaders

Atlassian Community Events