开发者

Escaping a question mark character in a column name in NHibernate

开发者 https://www.devze.com 2023-03-01 14:28 出处:网络
I have an entity with a property whose column name contains a question mark.How do I map the column name so that an HQL query will correctly generate SQL with the column name wrapped appropriately (i.

I have an entity with a property whose column name contains a question mark. How do I map the column name so that an HQL query will correctly generate SQL with the column name wrapped appropriately (i.e. [] for SQL Server) instead of substituting a parameter for the question mark? I have tried wrapping the column name in backticks or square brackets but this d开发者_JAVA技巧oesn't work.


Backticks work fine for me. Remember to use them only in the mapping file, not in the HQL:

<property name="Data1" column="`Data1?`" />

This query:

session.CreateQuery("select Data1 from Foo").List();

Results in this SQL:

select foo0_.[Data1?] as col_0_0_
from Foo foo0_

Update: this is a bug in NHibernate 3.1. Jira issue created

0

精彩评论

暂无评论...
验证码 换一张
取 消