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:
As you probably know NHibernate’s configuration has some property oriented to mapping-to-DLL tasks.
For schema integration you can use
<property name="hbm2ddl.auto">create-drop</property>
Allowed values for hbm2dll are:
The new property is:
<property name="hbm2ddl.keywords">auto-quote</property>
Allowed values are:
When you have an instance of a configured configuration (just before call BuildSessionFactory) you can execute:
SchemaMetadataUpdater.QuoteTableAndColumns(configuration);
That’s all.
Take a look to this mapping:
<class name="Order">
<id type="int">
<generator class="native"/>
</id>
<property name="Select"/>
<property name="From"/>
<property name="And"/>
<property name="Column"/>
<property name="Name"/>
</class>
Well… now it is working fine without explicitly quote.
Enjoy NHibernate’s multi-RDBMS easy support.