java.sql.SQLException:意外的标记:REFERENCES

时间:2015-12-13 07:08:06

标签: java mysql sql hibernate postgresql

使用hibernate-sql映射时,我的Create Statement查询出现异常。这是创建语句(Postgres)及其抱怨的错误。 查询:

CREATE TABLE translation (
translation_id INTEGER NOT NULL DEFAULT nextval('translation_seq'::regclass) PRIMARY KEY,
category TEXT NOT NULL,
sub_category TEXT DEFAULT NULL,
prod_id INTEGER NOT NULL REFERENCES product(product_id),
date_created DATE DEFAULT now() NOT NULL,
expired BOOLEAN DEFAULT FALSE NOT NULL
);

测试中的异常/失败:

java.lang.RuntimeException: HypersonicAccessor.dbInitSchema() failure. 
at com.package1.package2.package3.database.HypersonicAccessor.dbInitSchema(HypersonicAccessor.java:210)
at com.package1.package2.package3.someDbConfig.initialize(ProdDbConfig.java:145)
at com.package1.package2.package3.backend.client.UpdaterTest.setUp(UpdaterTest.java:57)

Caused by: java.sql.SQLException: Unexpected token: REFERENCES in statement 
[CREATE TABLE TRANSLATION (TRANSLATION_ID BIGINT NOT NULL  PRIMARY KEY,
 CATEGORY VARCHAR NOT NULL,    SUB_CATEGORY VARCHAR DEFAULT NULL, 
  PROD_ID BIGINT NOT NULL REFERENCES]
at com.package1.package2.package3.database.HypersonicDatabase.execute(HypersonicDatabase.java:146)
at com.package1.package2.package3.database.HypersonicDatabase.runSqlScript(HypersonicDatabase.java:169)
at com.package1.package2.package3.database.HypersonicAccessor.runScriptList(HypersonicAccessor.java:123)
at com.package1.package2.package3.database.HypersonicAccessor.dbInitSchema(HypersonicAccessor.java:157)

我不确定我的查询是错还是其他。有什么可能是错的线索?这实际上与我之前通过的一些测试相同,但现在却没有。

0 个答案:

没有答案