littypreethkr wrote:
I think you can put the same escape char which is used in native SQL, like [] in mssql, "" in oracle etc...
No, I tried this first, because it
does work for column names in the Hibernate mapping file. I'm using mssql, putting square braces in the query makes Hibernate complain about an invalid left square brace in the HQL.
lielar wrote:
I don't think it can be done, like Java, there are some reserved words you can't use as identifiers.
There
has to be a way...
every DBMS has a way to escape field names that could be keywords, I'd have a hard time believing the Hibernate folks forgot to add that.
Also since most DBMS's have their own extensions to SQL, there's no way to actually know what the keywords
are, so without a way to escape field names in HQL strings, you're
never guaranteed that your query will work...
I mean in my particular case, the problematic field is named "key", which is a perfectly legitimate name for a field. Except "key" is a keyword in MS SQL, and now I have no way to construct those HQL queries for MS SQL...