Question

I'm trying to run database tests with HSQLDB (in-memory mode), but hbm2ddl won't create structures. It behaves as if a wrong SQL dialect was used, but the log shows the dialect is correctly set:

HCANN000001: Hibernate Commons Annotations {4.0.4.Final}
HHH000412: Hibernate Core {4.3.1.Final}
HHH000206: hibernate.properties not found
HHH000021: Bytecode provider name : javassist
Creating new JDBC DriverManager Connection to [jdbc:hsqldb:mem:sample]
HHH000400: Using dialect: org.hibernate.dialect.HSQLDialect
HHH000399: Using default transaction strategy (direct JDBC transactions)
HHH000397: Using ASTQueryTranslatorFactory
HV000001: Hibernate Validator 5.1.0.Final
HSEARCH000034: Hibernate Search 4.5.0.Final
HHH000227: Running hbm2ddl schema export
HHH000389: Unsuccessful: create table .dictionary (id bigint generated by default as identity (start with 1), created_on timestamp not null, status varchar(255) not null, updated_on timestamp not null, version_created_by varchar(250), description varchar(250) not null, key varchar(100) not null, scope varchar(100), parent_id bigint, primary key (id))
ERROR o.h.tool.hbm2ddl.SchemaExport - unexpected token: TABLE : line: 2

Later on, when constructing other SQL statements in tests, Hibernate issues very humorous exceptions like:

java.sql.SQLSyntaxErrorException: unexpected token: FROM required: FROM

I really don't know what causes this behaviour, esp. that logs confirm that SQL dialect matches the database used.

Was it helpful?

Solution

Turns out, in a schema-less database (just like HSQL in-memory), you MAY NOT set the Hibernate property

<prop key="hibernate.default_schema">${hibernate.default_schema}</prop>

in any way whatsoever (leaving it empty counts as setting it).

My setup was created for production and tests in mind, the property hibernate.default_schema being set to a schema name or left empty, in respective environments.

Thanks for hints that helped me get on track.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top