Edited by OutSystems on March 21, 2014 The feature described in this topic is not formally supported by OutSystems. OutSystems advises against using this feature, as it may lead to unexpected results. Customers should not expect any official support from use of this feature.
Hi everyone,
Since version 3.2, it's possible in the OutSystems Platform to configure the physical table name used to support Entities on the database.
Up until now, physical table names were in the form of OSUSR_<ESPACE_ID>_ENTITYNAME, where <ESPACE_ID> stands for an internal eSpace identifier. For example, an Entity named Client contained inside an eSpace with identifier 112 would have a physical table name of OSUSR_112_CLIENT.
This format presented some challenges :
- Because the eSpace identifier changed between environments (development, testing, production, etc), it was difficult to make direct connections to tables. This made external integrations difficult to achieve;
- It could be a difficult format to read, because long entity names would be truncated;
To alleviate this problem, version 3.2 now provides a configuration setting that can be used to specify one of three table name formats. This setting is called Compiler.DefaultPhysicalTableName and can be found in the file OSHEComp.exe.config, on your Hub Server installation folder root. Valid entries for this setting are :
- PREFIX_ESPACENAMEHASH_ENTITYNAME - This format uses the OutSystems prefix (OSUSR) followed by a hash of the eSpace name. The hash is unique for each eSpace name and will remain constant in different environments so it is safe to assume that the physical table name will also be equal. This is now the the default Hub Server mode.
- PREFIX_ESPACEID_ENTITYNAME - Equivalent to the old format, where the OutSystems prefix is followed by the internal eSpace identifier and the entity name.
- ENTITYNAME - This format was designed to be used in very particular situations where the name of the database tables is relevant outside the OutSystems Hub Server environment. For example, it can be useful if you wish to establish a Data Dictionary that is also available to third party tools and direct integrations. Also, it is easier to read and understand when accessing the database from external query tools (for example Query Analyzer). However, please note that this setting can pose security issues, because the OutSystems Hub Server will not be able to make run-time checks on table access. This means that, for example, Advanced Queries will be able to access tables from other eSpaces directly by just referring to it's physical table name.
You will need to restart OutSystems Services in order to apply the new settings.
As a final note, please remember that changes made to this setting will only affect Entities created from that moment on. This means that if you publish an already existent eSpace any Entities that already existed will keep their original table names. However, if you create new entities, these will be affected by the new value for this setting.
Stay well!
Gonçalo
Joost said:I think you should read this post about integrating with an external-db: https://www.outsystems.com/NetworkForums/ViewTopic.aspx?TopicId=7362
Lots of your possible issues will be solved and you keep the benefit of the Outsystems Platform.(except the extremely easy and fast way of altering tables)
Thank you Joost. The workflow discussed in this thread is for tables manually created in a SQL database and later changes in the tables are manually maintained (by the DBA or the developer) and then use the integration studio to refresh these changes back into the entities used by the AP's application. This method does not show that changes to the entities in the ServiceStudio can be reflected to their original tables in the SQL database they were migrated from. Meaning the refresh is really one way rather than being two ways.
What you describe as “extremely easy and fast way of altering tables” I actually find it in more in AP rather than in the management studio. It’s the ease and convenience of querying and inspecting the data during the development process is what mostly will be lost with the AgilePlatform.
André said:I would assess creating denormalized views or even tables for the reports. IMHO you should keep business logic out of the reporting tools, they should be used just for that, rendering a report.
Problem that querying and reporting tools need to cope with changes made to entity tables from service studio. If we create specialized views then just maintaining changes in the entities back to these denormalized views becomes a maintenance nightmare doubled by the fact that entity tables are not directly named against their entities and that each entity table will change its name reflecting the new version of the entity.
If during the code generation process, AgilePlatform generates a single SQL view for every entity in addition to generating the table and also updates this SQL view to always use the latest version of the entity table, then database query and reporting tools can easily do their work the same they would do in the traditional world of simple named tables. Having these SQL views is like having best of both worlds; versioned tables for front-end application entities and SQL views for back-end database and reporting tools.
Pedro said:During my development process, I quite often find myself querying the database to see how my entity data looks like, or to test some options for some advanced queries.
That’s a great reason for me asking for these SQL views that are directly mapped to AP Entities.
Pedro said:
Pedro said: In order to facilitate the creation of the views you ask for, I've developed a simple espace that enables you to download a DDL file with the code needed to create such views. I didn't finished it yet, but I'm more than happy to share it with you and the rest of the community. If you find it useful and wish to provide some enhancements to it, it would be great.
That would be great and I know for myself and many other possible adopters of AgilePlatform, such functionality automation will make it that much easier to convert to AgilePlatform as it would not deprive us “traditional developers” from the way we are used to dealing with the data of our applications’ databases and at the same time we gain the phenomenal flexibility and power of the AgilePltaform applications.