2012-04-20 2 views
1

При добавлении нового порядка сущностей и запуска приложения i m, получающего это сообщение об ошибке MYSQL в моем cmd, может кто-нибудь сказать мне, почему я получаю такую ​​ошибку.Ошибки MySQL с Grails

| Error 2012-04-21 00:03:28,002 [Thread-7] ERROR hbm2ddl.SchemaUpdate - Unsucce 
ssful: create table order (id bigint not null auto_increment, version bigint not 
null, customer_id bigint not null, item_id bigint not null, notes varchar(255) 
not null, order_date datetime not null, order_price varchar(255) not null, qty v 
archar(255) not null, taken_by varchar(255) not null, primary key (id)) ENGINE=I 
nnoDB 
| Error 2012-04-21 00:03:28,006 [Thread-7] ERROR hbm2ddl.SchemaUpdate - You hav 
e an error in your SQL syntax; check the manual that corresponds to your MySQL s 
erver version for the right syntax to use near 'order (id bigint not null auto_i 
ncrement, version bigint not null, customer_id b' at line 1 
| Error 2012-04-21 00:03:28,008 [Thread-7] ERROR hbm2ddl.SchemaUpdate - Unsucce 
ssful: alter table item add index FK317B13A35B400E (order_id), add constraint FK 
317B13A35B400E foreign key (order_id) references order (id) 
| Error 2012-04-21 00:03:28,009 [Thread-7] ERROR hbm2ddl.SchemaUpdate - You hav 
e an error in your SQL syntax; check the manual that corresponds to your MySQL s 
erver version for the right syntax to use near 'order (id)' at line 1 
| Error 2012-04-21 00:03:28,011 [Thread-7] ERROR hbm2ddl.SchemaUpdate - Unsucce 
ssful: alter table order add index FK651874E47370946 (item_id), add constraint F 
K651874E47370946 foreign key (item_id) references item (id) 
| Error 2012-04-21 00:03:28,013 [Thread-7] ERROR hbm2ddl.SchemaUpdate - You hav 
e an error in your SQL syntax; check the manual that corresponds to your MySQL s 
erver version for the right syntax to use near 'order add index FK651874E4737094 
6 (item_id), add constraint FK651874E47370946 fo' at line 1 
| Error 2012-04-21 00:03:28,016 [Thread-7] ERROR hbm2ddl.SchemaUpdate - Unsucce 
ssful: alter table order add index FK651874EF3CCBB66 (customer_id), add constrai 
nt FK651874EF3CCBB66 foreign key (customer_id) references customer (id) 
| Error 2012-04-21 00:03:28,019 [Thread-7] ERROR hbm2ddl.SchemaUpdate - You hav 
e an error in your SQL syntax; check the manual that corresponds to your MySQL s 
erver version for the right syntax to use near 'order add index FK6 

51874EF3CCBB6 
6 (customer_id), add constraint FK651874EF3CCBB6' at line 1 
+0

dev environment? какая версия groovy/grails ?, можете ли вы переформатировать сообщение об ошибке для удобочитаемости? – vector

+0

@vector ..i m работает над windows..grails 2.0.0 ... groovy 1.8.3 .... Вот ошибка | Ошибка 2012-04-21 00: 03: 28,002 '[Thread-7] ERROR hbm2ddl.SchemaUpdate - Unsucce ssful: create table order (id bigint not null auto_increment, версия bigint not null, customer_id bigint not null, item_id bigint not (255) не null, took_by varchar (255) не null, первичный ключ (id)) ENGINE = 0, 0, 0, I ' nnoDB – sam1132

ответ

2

Вы не можете назвать таблицу order, так как это зарезервированное слово в синтаксисе SQL: http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html. Однако вы можете изменить свое имя таблицы на заказы с использованием сопоставлений:

class Order { 
    static mapping = { 
     table "orders" 
    } 
} 
+0

... хороший улов, есть ли способ «убежать» от него? – vector

+0

@Tomasz Gr8 Спасибо за помощь, что она работает сейчас – sam1132

+0

вы можете избежать этого с обратными шагами: '' table ''order''' ' –

Смежные вопросы