Removing characters [ and ] from name of table, column, sequece

Posts   
 
    
miron
User
Posts: 5
Joined: 31-May-2013
# Posted on: 31-May-2013 01:08:23   

SQLServer, nhibernate

Is there possibility to remove character for name of table, column, sequence and other?

E.g. table="[PERSON]"

With these character [ and ] hibernate has problem with upgrading database schema. When I use UpdateSchema hibernate still generate exception that table exists.

When I remove [ ] upgrading is working.

Maybe it is a bug in nhibernate? Because others functionality in hibernate with [ ] is working.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 31-May-2013 08:07:32   
  • What is your LLBLGen version?
  • What NHibernate preset are you using (Fluent, mapping classes)?
  • What is your NHibernate runtime library version?
David Elizondo | LLBLGen Support Team
miron
User
Posts: 5
Joined: 31-May-2013
# Posted on: 31-May-2013 09:23:21   

daelmo wrote:

  • What is your LLBLGen version?
  • What NHibernate preset are you using (Fluent, mapping classes)?
  • What is your NHibernate runtime library version?

Thank you for your answer.

LLBLGen Pro 4.0 Final - LITE May 15th, 2013

Nhibernate 3.3.3.4000 Xml mapping classes

I have also tried 3.3.2. But it was the same result.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39910
Joined: 17-Aug-2003
# Posted on: 31-May-2013 10:44:43   

LITE version users don't get support, I'm sorry.

Lite limitations LLBLGen Pro Lite is free, but is limited to 8 entities per project and comes with no support. If you want to create projects with more entities, please purchase a per-seat license. Code generated with the Lite version may be used for production purposes.

Though, we're not horrible people, so I'll give you a hint wink -> the generated mapping files don't contain enough information for nhibernate to create the schema at runtime, e.g. we don't emit DB types into the mapping files. We don't do that because it will pollute the mapping files with info which isn't used normally. The designer offers a way to export create / update scripts from the model. You should use these scripts to create / update the schema of your DB, because they're created from the model itself.

I don't know why nhibernate chokes on [], as these characters are required to produce proper names in many situations (e.g. spaces in table names, other characters like '\' in table names etc.) perhaps you picked the wrong dialect?

Frans Bouma | Lead developer LLBLGen Pro
miron
User
Posts: 5
Joined: 31-May-2013
# Posted on: 31-May-2013 15:18:33   

Otis wrote:

LITE version users don't get support, I'm sorry.

Lite limitations LLBLGen Pro Lite is free, but is limited to 8 entities per project and comes with no support. If you want to create projects with more entities, please purchase a per-seat license. Code generated with the Lite version may be used for production purposes.

Though, we're not horrible people, so I'll give you a hint wink -> the generated mapping files don't contain enough information for nhibernate to create the schema at runtime, e.g. we don't emit DB types into the mapping files. We don't do that because it will pollute the mapping files with info which isn't used normally. The designer offers a way to export create / update scripts from the model. You should use these scripts to create / update the schema of your DB, because they're created from the model itself.

I don't know why nhibernate chokes on [], as these characters are required to produce proper names in many situations (e.g. spaces in table names, other characters like '\' in table names etc.) perhaps you picked the wrong dialect?

  1. We want to buy full version. But before we would like all feature which we wish in this tool.
  2. Default types for columns is ok.
  3. When I remove character: '[' ']' e.g. [COLUMNA_NAME] SchemaUpdate work ok. I have modified script to gen entities (this script is removing this characters. But maybe there is better solution Mirek
miron
User
Posts: 5
Joined: 31-May-2013
# Posted on: 31-May-2013 15:19:26   

Otis wrote:

LITE version users don't get support, I'm sorry.

Lite limitations LLBLGen Pro Lite is free, but is limited to 8 entities per project and comes with no support. If you want to create projects with more entities, please purchase a per-seat license. Code generated with the Lite version may be used for production purposes.

Though, we're not horrible people, so I'll give you a hint wink -> the generated mapping files don't contain enough information for nhibernate to create the schema at runtime, e.g. we don't emit DB types into the mapping files. We don't do that because it will pollute the mapping files with info which isn't used normally. The designer offers a way to export create / update scripts from the model. You should use these scripts to create / update the schema of your DB, because they're created from the model itself.

I don't know why nhibernate chokes on [], as these characters are required to produce proper names in many situations (e.g. spaces in table names, other characters like '\' in table names etc.) perhaps you picked the wrong dialect?

I am testing for SQL Server 2008. Dialect for SQL Server 2008.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39910
Joined: 17-Aug-2003
# Posted on: 31-May-2013 21:18:29   

miron wrote:

Otis wrote:

LITE version users don't get support, I'm sorry.

Lite limitations LLBLGen Pro Lite is free, but is limited to 8 entities per project and comes with no support. If you want to create projects with more entities, please purchase a per-seat license. Code generated with the Lite version may be used for production purposes.

Though, we're not horrible people, so I'll give you a hint wink -> the generated mapping files don't contain enough information for nhibernate to create the schema at runtime, e.g. we don't emit DB types into the mapping files. We don't do that because it will pollute the mapping files with info which isn't used normally. The designer offers a way to export create / update scripts from the model. You should use these scripts to create / update the schema of your DB, because they're created from the model itself.

I don't know why nhibernate chokes on [], as these characters are required to produce proper names in many situations (e.g. spaces in table names, other characters like '\' in table names etc.) perhaps you picked the wrong dialect?

  1. We want to buy full version. But before we would like all feature which we wish in this tool.

Then please download the trial version and request a trial license.

  1. Default types for columns is ok.
  2. When I remove character: '[' ']' e.g. [COLUMNA_NAME] SchemaUpdate work ok. I have modified script to gen entities (this script is removing this characters. But maybe there is better solution Mirek

You can just export the create schema script and if you change the model, an update schema script: http://www.llblgen.com/documentation/4.0/QuickStartGuides/mf_createscripts.htm

Frans Bouma | Lead developer LLBLGen Pro
miron
User
Posts: 5
Joined: 31-May-2013
# Posted on: 01-Jun-2013 18:14:42   

Otis wrote:

miron wrote:

Otis wrote:

LITE version users don't get support, I'm sorry.

Lite limitations LLBLGen Pro Lite is free, but is limited to 8 entities per project and comes with no support. If you want to create projects with more entities, please purchase a per-seat license. Code generated with the Lite version may be used for production purposes.

Though, we're not horrible people, so I'll give you a hint wink -> the generated mapping files don't contain enough information for nhibernate to create the schema at runtime, e.g. we don't emit DB types into the mapping files. We don't do that because it will pollute the mapping files with info which isn't used normally. The designer offers a way to export create / update scripts from the model. You should use these scripts to create / update the schema of your DB, because they're created from the model itself.

I don't know why nhibernate chokes on [], as these characters are required to produce proper names in many situations (e.g. spaces in table names, other characters like '\' in table names etc.) perhaps you picked the wrong dialect?

  1. We want to buy full version. But before we would like all feature which we wish in this tool.

Then please download the trial version and request a trial license.

  1. Default types for columns is ok.
  2. When I remove character: '[' ']' e.g. [COLUMNA_NAME] SchemaUpdate work ok. I have modified script to gen entities (this script is removing this characters. But maybe there is better solution Mirek

You can just export the create schema script and if you change the model, an update schema script: http://www.llblgen.com/documentation/4.0/QuickStartGuides/mf_createscripts.htm

No, unfortunetly it is not best solution for us. Update should be doing on users computer. And users can has different version of database schema.

I wrote about this issue on nhusers group. I got answer:

========================

Try using instead, like in table="PERSON`" or better yet using the AutoQuote flag in the configuration. Loquacious:

NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration()
.DataBaseIntegration(db =>
{
    db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
    ///...
}

Or XML:

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory>
        <property name="hbm2ddl.keywords">auto-quote</property>
...

=========================

link to this answer: https://groups.google.com/forum/?fromgroups#!topic/nhusers/1rRxqu4gYBM

What is your proposition to solve this issue?

Using quota would be good but how to switch off adding [ ] in name of tables, columns, sequences (and maybe other database objects)?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 03-Jun-2013 07:31:43   

There is not a switch to turn off emit []. I advise you to investigate further on NH side (support, forums, etc.) to see if there is a solution there.

You can change this manually on the HN template: LLBLGen installation folder\Frameworks\NHibertnate\Shared\Shared\generalTemplateUtils.lpt:406. You can create your own version of the templates to override just this file, for more information please read the SDK documentation.

David Elizondo | LLBLGen Support Team