1

添加新实体订单并运行应用程序时,我在我的 cmd 中收到此 MYSQL 错误消息,谁能告诉我为什么会收到这样的错误。

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

1 回答 1

2

您无法命名表order,因为它是 SQL 语法中的保留字:http: //dev.mysql.com/doc/refman/5.5/en/reserved-words.html。但是,您可以使用映射将表名更改为订单:

class Order {
    static mapping = {
        table "orders"
    }
}
于 2012-04-20T14:30:23.783 回答