How escape column names?

319 views
Skip to first unread message

Felipe Oriani

unread,
Jun 21, 2016, 10:11:11 AM6/21/16
to nhu...@googlegroups.com
Hello guys, 

I've developing a project with NHibernate and Oracle. We have a table which has a column named Level and Level is a keyword used on oracle, which we should escape with quotes to make a sql statement. I've looking how to do it on NHibernate and I saw we have a configuration that we can add on the hibernate.cfg.xml, like this tag:

    <property name="hbm2ddl.keywords">auto-quote</property>

We saw it on the Fabio Maulo's blog, and we understand it should escape all the table/column names with quotes, but it does not work fine to me. Instead "auto-quote" we also tried "keywords" but we have gotten the same result.

I know we can change our mapping and force to map the column name with quotes, but it looks like a workaround for us. Is there any way to get the column names escaped with quotes for the sql statements?

Thank you.

--
______________________________________
Felipe B Oriani

Paulo Quicoli

unread,
Jun 21, 2016, 10:22:29 AM6/21/16
to nhu...@googlegroups.com
I believe it should work if you are using xml mapping...


Bye

--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nhusers+u...@googlegroups.com.
To post to this group, send email to nhu...@googlegroups.com.
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.

Oskar Berggren

unread,
Jun 21, 2016, 10:26:32 AM6/21/16
to nhu...@googlegroups.com
The NHibernate quote character is the backtick - NH will translate to suitable character for DB dialect.

--

Felipe Oriani

unread,
Jun 21, 2016, 10:45:31 AM6/21/16
to nhu...@googlegroups.com
Yes, I'm using Fluent NH to map, but to configure I have the hibernate.cfg.xml and I load it and merge with fluent configuration. I do it to keep the database configuration flexible to change. I know the configuration is been added but with oracle here it is not working.

I will try to change the convention name such as the post Paulo suggested.

Oskar, is there any place I can find the quote character following the database configured?

Thank you


Oskar Berggren

unread,
Jun 21, 2016, 11:01:18 AM6/21/16
to nhu...@googlegroups.com
The dialect specific quite character that NH will apply for you is found in the source code of each dialect.

Felipe Oriani

unread,
Jun 21, 2016, 11:04:13 AM6/21/16
to nhu...@googlegroups.com
The problem is that even configuring on the hibernate.cfg.xml the tag:

    <property name="hbm2ddl.keywords">auto-quote</property>

Or on the ExposeConfiguration method of Fluent NH, it seems doesn't work for Oracle.

Oskar, do you have any suggestion?

Thank you.


Reply all
Reply to author
Forward
0 new messages