How to read Jira AO table from other Plugin

I have a plugin plugin1 where I am performing crud operation on my AO table(table name - AO_D26215_CCDENTITY), now I’m writing a new plugin Plugin2 where I want to read that table.
I created same entity class
String sql = “SELECT * FROM AO_D26215_CCDENTITY WHERE TYPE = ?”;
CCDEntity results = ao.findWithSQL(CCDEntity.class, sql, type);

but internally it creating new AO table AO_7AF461_AO_D26215_CCDENTITY and resulting 0 record.

How can I restrict my plugin , not to create new AO table instead pull data from provided AO table of other plugin ?

It is not possible to access other plugin’s active objects due to the design of sandboxing.

You can write raw SQL with org.ofbiz.core.entity.jdbc.ReadOnlySQLProcessor, it won’t be pretty, but you’ll be able to fetch whatever you need.

If you own both plugins, you should probably export a public OSGi service from plugin1 and use that service in plugin2 to work with that data.

1 Like