views:

48

answers:

1

i have class named Group

i tried to test configuration:

var cfg = new Configuration();
cfg.Configure();

cfg.AddAssembly(typeof (Group).Assembly);

new SchemaExport(cfg).Execute(true, true, false);

when i debug this, im getting following sql:

 create table Group (
        ID INT IDENTITY NOT NULL,
       Name NVARCHAR(255) null,
       CreatedDate DATETIME null,
       primary key (ID)
    )

so like i remember, Group key reserved for Group By

so why NHibernate does not uses quotes like Group for table names?

BTW, I'm using Sql Server 2005 and NHibernate 2.1

+1  A: 

If you are using a reserved keyword as your object name you should mark it with a DBMS specific sign. For example if you are using SQL Server you should put it in [] and use ` for MySql. In this example you should write (assuming that you are using SQL server) :

<class name="Group" table="[Group]">
Beatles1692
In NHibernate, you can use ` and it will be translated to the appropriate database quoting mechanism.
Sean Carpenter
thanks! I didn't know that :)
Beatles1692