Since long time we have a very interesting request on NHibernate JIRA (NH-188).
If you are working in a multi-RDBMS application, you are annoyed, for sure, quoting a table-name or a column-name. As a very good persistent-layer this should be a NHibernate’s work.
I’m happy to announce that the problem is solved (even if, so far, is not done by default).
If you want that NH take the responsibility of properly quote table-name or column-name only where really needed now you can do it in two ways:
- Through configuration
- Explicitly by code
As you probably know NHibernate’s configuration has some property oriented to mapping-to-DLL tasks.
For schema integration you can use
Allowed values for hbm2ddl are:
- update : auto execute SchemaUpdate on BuildSessionFactory
- create : auto execute SchemaExport on BuildSessionFactory
- create-drop : auto execute SchemaExport on BuildSessionFactory recreating the schema
- validate : auto execute SchemaValidator on BuildSessionFactory
The new property is:
Allowed values are:
- none : disable any operation regarding RDBMS KeyWords
- keywords : (activated by Default)imports all RDBMS KeyWords where the NH-Dialect can provide the implementation of IDataBaseSchema (so far available for MsSQL, Oracle, Firebird, MsSqlCe, MySQL, SQLite, SybaseAnywhere)
- auto-quote : imports all RDBMS KeyWords and auto-quote all table-names/column-names on BuildSessionFactory
Explicitly by code
When you have an instance of a configured configuration (just before call BuildSessionFactory) you can execute:
Take a look to this mapping:
Well… now it is working fine without explicitly quote.
Enjoy NHibernate’s multi-RDBMS easy support.