Schema name hardcoded in generated code

Posts   
 
    
kimkim
User
Posts: 19
Joined: 12-Sep-2007
# Posted on: 03-Sep-2008 16:25:04   

I am using LLBLGen version 2.5 Final with .NET 2.0 and an Oracle 10g database. My problem is that in the generated code (ActionProcedures.cs, RetrievalProcedures.cs etc) the schema name is harded coded in as follows:

adapter.CallRetrievalStoredProcedure("schema_name.procedure_name", parameters, toReturn);

How can this code be generated without the schema name included?

Also, in the PersistenceInfoProvider.cs class, the name of the database server is included in the base.AddElementMapping() call.

This will cause a problem when I go to deploy the system on the clients database, which has a different name and schema name.

Thanks.

Kimkim

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 03-Sep-2008 16:46:19   

Please check Schema name overwriting in the docs, "Using the enerated code -> Application configuration through .config files" section.

kimkim
User
Posts: 19
Joined: 12-Sep-2007
# Posted on: 03-Sep-2008 17:24:51   

Thanks for your reply. In the sample code for the Oracle schema name overwrite below:

<oracleSchemaNameOverwrites> <add key="SCOTT" value="HR" /> </oracleSchemaNameOverwrites>

does "SCOTT" refer to the schema name and "HR" the password?

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 03-Sep-2008 18:01:43   

<oracleSchemaNameOverwrites> <add key="SCOTT" value="HR" /> </oracleSchemaNameOverwrites>

does "SCOTT" refer to the schema name and "HR" the password?

No, the password is specified in the connectionString.

SCOTT in the above example specifies the original schema name, the one you used to generate the code. (The one you have found hardcoded in the code).

And "HR" is the new schema name, the one you are using in the new deployment.

kimkim
User
Posts: 19
Joined: 12-Sep-2007
# Posted on: 04-Sep-2008 11:58:05   

Thanks for that.

Regarding the database server being hardcoded into the PersistenceInfoProvider.cs class, is there a way around this?

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 04-Sep-2008 12:33:15   

The database server is not generated into the PersistenceInfoProvider, there must be a mistake here.

Anyway you should set the dataSource attribute of the ConnectionString to the tns name created at your machine that aliases the database server.

kimkim
User
Posts: 19
Joined: 12-Sep-2007
# Posted on: 04-Sep-2008 12:58:17   

It is the TNS name that is hardcoded into this file as follows:

base.AddElementMapping( "Entity_Name", "TNS_NAME", @"SCHEMA_NAME", "TABLE_NAME", 17 );

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 04-Sep-2008 13:13:55   

So did you try to change it in the connection string of your application config file and it still refers to the old one?

kimkim
User
Posts: 19
Joined: 12-Sep-2007
# Posted on: 04-Sep-2008 13:45:30   

I don't understand, how will changing the tns name in the web.config file change the hardcoded tns name in the generated PersistenceInfoProvide.cs class? Does it change at runtime like the schema name?

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 04-Sep-2008 13:59:29   

From my past experience with Oracle, I'd say the one in the connectionString is the one used at runtime.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 04-Sep-2008 15:15:00   

The catalog name isn't used for Oracle queries, it's there to make the code generic. Oracle uses schemas. The Catalog name can be changed in the catalog explorer, however it's of no use in oracle projects, as oracle uses schemas.

Frans Bouma | Lead developer LLBLGen Pro
JLLo avatar
JLLo
User
Posts: 18
Joined: 03-Nov-2008
# Posted on: 14-Apr-2009 19:54:43   

Otis wrote:

The catalog name isn't used for Oracle queries, it's there to make the code generic. Oracle uses schemas. The Catalog name can be changed in the catalog explorer, however it's of no use in oracle projects, as oracle uses schemas.

Hey Otis, Are you saying here that it doesn't matter what the schema name is? In my case I have my development schema jllo.tableName. When I deploy my application to production it will be clientUser.tableName.

If I understand what you are saying the schema name is only used in the Designer and the application is "schema-neutral" or should work. Correct or am I missing something?

Thanks, James

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 14-Apr-2009 20:20:50   

For Oracle, the schema does matter, the catalog doesn't matter. Oracle doesn't have the concept of 'catalog', Oracle uses schemas.

David Elizondo | LLBLGen Support Team
JLLo avatar
JLLo
User
Posts: 18
Joined: 03-Nov-2008
# Posted on: 14-Apr-2009 20:25:06   

daelmo wrote:

For Oracle, the schema does matter, the catalog doesn't matter. Oracle doesn't have the concept of 'catalog', Oracle uses schemas.

Thanks David, So then when I create my llblgen data class I need to make sure the schema I use to connect is the same schema I'll use in production?

I don't mean to be dense but I want to ensure I fully comprehend the deal.

One thing I did was (prior to compiling the llblgen class) to search all the files generated by llblgen for the schema name. I found it in only one file (PersistenceInfoProvider.cs).

I'm thinking I can just replace the instances of my development db schema name with the production schema name, re-compile the llblgen class then I'm good to go. Does that sound right to you?

Thanks again, James

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 15-Apr-2009 11:24:34   

I'm thinking I can just replace the instances of my development db schema name with the production schema name, re-compile the llblgen class then I'm good to go. Does that sound right to you?

You can do that.

And also you can manage this through the config file of your application simple_smile Please check Schema name overwriting

JLLo avatar
JLLo
User
Posts: 18
Joined: 03-Nov-2008
# Posted on: 15-Apr-2009 11:40:48   

And also you can manage this through the config file of your application simple_smile Please check Schema name overwriting

Hey thanks, Yea I saw that. Looks like it will work.

Thanks