New Posts New Posts RSS Feed: Need to be able to set table owner name at runtime running against Oracle server
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Need to be able to set table owner name at runtime running against Oracle server

 Post Reply Post Reply
Author
Customer View Drop Down
Senior Member
Senior Member
Avatar
User Submitted Questions to Support

Joined: 30-May-2007
Location: United States
Posts: 260
Post Options Post Options   Quote Customer Quote  Post ReplyReply Direct Link To This Post Topic: Need to be able to set table owner name at runtime running against Oracle server
    Posted: 12-Jul-2007 at 2:22pm

We need an easy way to change which database owner an object points to at run time, ideally for all of the objects in the ORM tool.  Basically, we need the ability for the database to be dynamic, but because the "owner" is more of a user in oracle, its limiting us to one user.

EG, if the owner for all the objects is 'TEST', it currently says 'select * from test.table'. We need the 'test' part to be dynamic.

I remember asking about this before at some point and it was mentioned that the new version of ideablade supports this, but I'm not sure how to go about implementing a change.

Any suggestions are appreciated.

Back to Top
IdeaBlade View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 30-May-2007
Location: United States
Posts: 353
Post Options Post Options   Quote IdeaBlade Quote  Post ReplyReply Direct Link To This Post Posted: 12-Jul-2007 at 2:23pm
In general what you need to resolve this problem is to implement a class in your business objects assembly that derives from the DataSourceMappingInterceptor class.   Some documentation of this class is found in the Help Reference under the IdeaBlade.Persistence namespace, which this class is part of.  DataSourceMappingInterceptors are also mentioned in the IdeaBlade Developer's Guide.
 
Here is an example of some code that changes the table owner name:
 

public class OracleMappingInterceptor : DataSourceMappingInterceptor {

 

    public override void UpdateSourceMapping(IDataSourceKey pKey, EntityTable pEntityTable) {

      RdbKey aRdbKey = pKey as RdbKey;

      if (aRdbKey == null || aRdbKey.DatabaseDriver.DatabaseProduct != DatabaseProduct.Oracle) {

        return;

      }

 

      RdbTableMappingInfo info = pEntityTable.TableMappingInfo as RdbTableMappingInfo;

      info.SchemaInitializationMode = SchemaInitializationMode.FromDataSource;

      info.SourceOwnerName = "SA";

      info.SourceTableName = info.SourceTableName.ToUpper();

      info.SourceColumnNames = info.SourceColumnNames.ToUpper();

      foreach (DataColumnMapping columnMapping in info.TableMapping.ColumnMappings) {

        columnMapping.SourceColumn = columnMapping.SourceColumn.ToUpper();

      }

      if (info.ColumnInsertMap.ContainsKey("RowVersion")) {

        info.ColumnInsertMap["RowVersion"] = info.ColumnInsertMap["RowVersion"].ToUpper();

      }

      if (info.ColumnUpdateMap.ContainsKey("RowVersion")) {

        info.ColumnUpdateMap["RowVersion"] = info.ColumnUpdateMap["RowVersion"].ToUpper();

      }

    }

 


Edited by IdeaBlade - 13-Jul-2007 at 9:57am
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down