我今天启动了我的应用程序,当它启动时出现此错误
| Error 2012-09-14 13:54:17,608 [pool-7-thread-1] ERROR hbm2ddl.SchemaExport - Unsuccessful: create table order (id bigint generated by default as identity, version bigint not null, date_created timestamp not null, order varchar(255) not null, picture_id bigint not null, posts_id bigint not null, primary key (id))
| Error 2012-09-14 13:54:17,609 [pool-7-thread-1] ERROR hbm2ddl.SchemaExport - Syntax error in SQL statement "CREATE TABLE ORDER[*] (ID BIGINT GENERATED BY DEFAULT AS IDENTITY, VERSION BIGINT NOT NULL, DATE_CREATED TIMESTAMP NOT NULL, ORDER VARCHAR(255) NOT NULL, PICTURE_ID BIGINT NOT NULL, POSTS_ID BIGINT NOT NULL, PRIMARY KEY (ID)) "; expected "identifier"; SQL statement: create table order (id bigint generated by default as identity, version bigint not null, date_created timestamp not null, order varchar(255) not null, picture_id bigint not null, posts_id bigint not null, primary key (id)) [42001-164]
| Error 2012-09-14 13:54:17,621 [pool-7-thread-1] ERROR hbm2ddl.SchemaExport - Unsuccessful: alter table order add constraint FK651874E9A8021F6 foreign key (posts_id) references post
| Error 2012-09-14 13:54:17,621 [pool-7-thread-1] ERROR hbm2ddl.SchemaExport - Syntax error in SQL statement "ALTER TABLE ORDER[*] ADD CONSTRAINT FK651874E9A8021F6 FOREIGN KEY (POSTS_ID) REFERENCES POST "; expected "identifier"; SQL statement: alter table order add constraint FK651874E9A8021F6 foreign key (posts_id) references post [42001-164]
| Error 2012-09-14 13:54:17,621 [pool-7-thread-1] ERROR hbm2ddl.SchemaExport - Unsuccessful: alter table order add constraint FK651874ED45FCA4B foreign key (picture_id) references picture
| Error 2012-09-14 13:54:17,621 [pool-7-thread-1] ERROR hbm2ddl.SchemaExport - Syntax error in SQL statement "ALTER TABLE ORDER[*] ADD CONSTRAINT FK651874ED45FCA4B FOREIGN KEY (PICTURE_ID) REFERENCES PICTURE "; expected "identifier"; SQL statement: alter table order add constraint FK651874ED45FCA4B foreign key (picture_id) references picture [42001-164]
有没有人见过这个?
最佳答案
GORM 中有一些关键字是不允许的:order、group 或任何其他 SQL 关键字;你也不能命名域类用户、组(PostgreSQL)。
要修复它,请阅读 mapping并更改表名和列。
关于以数据库错误开头的 Grails 有没有人看到这个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12425104/