I'm having a problem with my ORMLite package ( http://ormlite.sourceforge.net/ ). When I generate the schema for a table, I thought it would be a good practice to escape all entity names. This would protect some Java class or field name from being a SQL reserved word:
CREATE TABLE "footable" ("stuff" VARCHAR(255))
I'm now adding "raw" query support so that ORMLite can help users perform their own queries. However, I find that with Derby and Hsqldb, the entity names cannot be used without escaping. For example, the following query:
SELECT * FROM footable
generates the following errors:
Derby: ERROR 42X05: Table/View 'FOOTABLE' does not exist.
Hsqldb: Table not found in statement [select * from footable]
It works fine if the select table is also escaped as "footable"
. The other databases supported by ORMLite work fine with or without the escaping: MySQL, Postgres, Microsoft SQL Server, H2, and Sqlite.
Are there better ways to escape reserved words in Derby and Hsqldb? Other ideas about how to do this in a portable manner?
Thanks.