For a project I am currently working on using ColdFusion 9’s ORM Hibernate, I recently found myself in a situation where I wanted to name a table using the Oracle reserved word ‘User’.
I set up my mapping hoping that Hibernate would just take care of it for me…
1 2 3 4 |
|
…oh, if life were just that easy.
ColdFusion kindly returned me this error:
Error while executing the Hibernate query. java.sql.SQLSyntaxErrorException:[Macromedia][Oracle JDBC Driver][Oracle]ORA-00903: invalid table name
Escaping reserved words in Oracle is simple, you just need to wrap the words in the special character grave accent
(ASCII Code 96). Easy enough right? Maybe not… when escaping reserved words while mapping Hibernate entities and properties it is important to note… escaped mappings are case sensitive, major gotchya.
So if your table name is ‘USER’, this will not work:
1 2 3 4 |
|
Thus, when escaping a mapping when working with Oracle… you also need to ensure the mapping’s case matches the table or column name’s case in your database.
1 2 3 4 |
|
Hopefully this saves somebody some confusion.