Your issue is that COUNT
is a reserved keyword for HSQL, but not for Oracle.
According to the HSQL documentation, it might still be possible to use COUNT
as identifier, if you either
Mask it as described in the Hibernate documentation or in the JPA spec (cf. chapter 2.13 from the JPA 2 spec; you'll need to accept their license agreement). Note that the JPA spec speaks of double quotes whereas the Hibernate documentation mentions backticks (which will be converted to the appropriate character according to the database dialect in use).
From the hibernate documentation:
You can force Hibernate to quote an identifier in the generated SQL by
enclosing the table or column name in backticks in the mapping
document. Hibernate will use the correct quotation style for the SQL
Dialect. This is usually double quotes, but the SQL Server uses
brackets and MySQL uses backticks.
From the JPA 2 spec:
Using annotations, a name is specified as a delimited identifier by
enclosing the name within double quotes, whereby the inner quotes are
escaped, e.g., @Table(name="\"customer\"")
.
Configure HSQL to allow it by executing SET DATABASE SQL NAMES FALSE
(however, this should already be the default setting and it will only allow "the use of most keywords", not all - edit: COUNT
will still be disallowed as per documentation)
My recommendation would be to avoid using identifiers if possible as you never know what problems may arise elsewhere (e.g. one might think Hibernate would be able to mask keywords itself) and use something like COUNT1
instead as column name.
The above part of the JPA spec also explains why Hibernate does not mask the name itself:
By default, the names of database objects must be treated as
undelimited identifiers and passed to the database as such.
The JPA spec also mentions a <delimited-identifiers/>
option "to specify that all database identifiers in use for a persistence unit be treated as
delimited identifiers", but this seems to be only usable with an XML mapping file.