繁体   English   中英

使用HSQL休眠-未使用hbm2ddl创建表

[英]Hibernate with HSQL - tables are not being created with hbm2ddl

我正在尝试使用HSQLDB(内存模式)运行数据库测试,但是hbm2ddl无法创建结构。 它的行为就像使用了错误的SQL方言一样,但是日志显示方言已正确设置:

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

稍后,在测试中构造其他SQL语句时,Hibernate发出非常幽默的异常,例如:

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

我真的不知道是什么原因导致了这种行为,尤其是。 该日志确认SQL方言与使用的数据库匹配。

事实证明,在无模式的数据库中(就像HSQL在内存中一样),您不能设置Hibernate属性

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

无论如何(将其保留为空均视为设置)。

我的设置是为生产和测试而创建的,将hibernate.default_schema属性设置为架构名称或在各个环境中保留为空。

感谢您提供的提示,这些提示有助于我步入正轨。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM