Advanced query without adding a reference to an entity in an espace

Advanced query without adding a reference to an entity in an espace

  

Hi all,

I am working on Java/Oracle stack of outsystems 9.1.x, can someone suggest me a way to write an advanced query without adding the reference of the entity in that espace.

If not, Is there some forge components/ example extensions using the RuntimePublic.Db APIs that I can reuse to execute a query and get back the output in a structure.

Thanks.






Hello Prayaag,

Why you don't want to add a reference for the entity in your eSpace?

Cheers,
Eduardo Jauch

Hi Eduardo,

Both the espace are in two complete different applications. Think of it as Application A and Application B having its own set of espaces.

Application A is to be deployed first and Application B refers to espaces and entities from Application A. But now there has been a requirement where from Application A I need to refer an entity within application B. Refactoring Application A to move the espaces to App B will be a time consuming process. 

If I do a direct reference from Application A to B deployment of Application A will fail and there would be a situation of cyclic dependencies, hence the question how to query the entity without adding the reference. 

There is very less likely chances of the entity in Application B being refactored, so if you know of any clean way of achieving this it would be helpful.

Thanks

Hi Prayaag,


The standard approach would be in fact, refactor. But not passing things from A to B or B to A.
Instead, the scenario you have is to move what you need from A and B to C (new module), so both A and B now consume C. But move entities from modules, if the application is already in production, will require extra care because of the DATA, probably requiring you to export and import all required data, remaking the relationships because of the FK's.

I'm not sure, but I think there is a component in forge that can help with this. I think is this one: Refactor.

This way, you are creating a better architecture.

I see only two other options. The first is that if you name schema for the tables are not the standard (OutSystems take care of the name) but the one were the name of the Entities are also the name of the physical tables (without the suffixes and so on). Than, in this case, with an advanced query you could access the entities directly in the database with its physical name.

The second is through a Local Web Service. You expose a WebService in application A and consume it in B. This way you don't use references.

Hope this helps,

Cheers,
Eduardo Jauch

Hi Prayaag,

There is only one way to do by using Web Service.

Thanx,

-HM-

Hi Prayaag.

Cyclic dependencies will not cause deployment failures. Certainly they are not recommended, because it's more difficult to debug, reason, and also scale when you have too many interdependencies. But adding the cyclic reference would be a simple solution to your case.

Refactoring your application to have a separate "shared" module would be the best solution.

Like others said, exposing the query through a web service is doable. But you will end up with the same problems as the cyclic dependencies: more difficult to debug, reason and scale. Besides, the web service consumer and producer won't share the same transaction, which could be a problem on your case.

You could write SQL code for accessing the tables directly. I remember there are some tricks to it to bypass some platform checks, so I don't advise you going that path just to spare a cyclic dependency.

Prayaag Gupta wrote:

Hi all,

I am working on Java/Oracle stack of outsystems 9.1.x, can someone suggest me a way to write an advanced query without adding the reference of the entity in that espace.

If not, Is there some forge components/ example extensions using the RuntimePublic.Db APIs that I can reuse to execute a query and get back the output in a structure.

Thanks.







Eduardo and Leonardo answered very well. I think and just to add, that using expand inline parameters (that's yours original solution) to achieve that, is the worst option in this scenarios. One example of this is: 

If you change the table in the application B you will not see the runtime impact that can cause in the application A because, in fact, you don't have any reference of the element and the Platform will not warn you. So you can add, delete or change attributes in the Application B without knowing (can happen because a new developer came in without that knowledge and changed the table, a different team is working in that project or just because later you forgot that, etc etc) leading to runtime errors.

My first advice would be following Eduardo suggestion: Like Eduardo said, the Espace C, shared by your applications, would be the best choice. 

If this has a lot of impact, I would create an API module that would explose the data you need. 

Today will be the entity A, tomorrow can be another one. Just pay attention to the architecture or business plans in the future to make the best choice :)

Kind regards

Prayaag Gupta wrote:

Hi all,

I am working on Java/Oracle stack of outsystems 9.1.x, can someone suggest me a way to write an advanced query without adding the reference of the entity in that espace.

If not, Is there some forge components/ example extensions using the RuntimePublic.Db APIs that I can reuse to execute a query and get back the output in a structure.

Thanks.






Hi Gupta,

what about: https://www.outsystems.com/forums/discussion/21999/how-to-call-oracle-stored-procedure-with-outputs-using-advance-query-sql/

regards,

IB