Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails starting with a database error has anyone seen this

Tags:

grails

ddl

I started my application today and when it starts I get this error

| 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]

Has anyone seen this before?

like image 541
Sagarmichael Avatar asked Sep 14 '12 12:09

Sagarmichael


2 Answers

There are some keys are not allowed in GORM: order, group or any other SQL keyword; also you can't name domain class User, Group(PostgreSQL).
To fix it read mapping and change table names and columns.

like image 58
Mr. Cat Avatar answered Nov 12 '22 02:11

Mr. Cat


I have found out you cannot have field or domain with the name: order, group or any other SQL keyword.

like image 37
Sagarmichael Avatar answered Nov 12 '22 01:11

Sagarmichael