首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Grails的MySQL错误

Grails的MySQL错误
EN

Stack Overflow用户
提问于 2012-04-20 22:24:02
回答 1查看 640关注 0票数 1

当添加一个新的实体订单并运行应用程序时,我的cmd中出现了这个MYSQL错误消息,有人能告诉我为什么会出现这样的错误吗?

代码语言:javascript
复制
| 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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-04-20 22:30:24

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

代码语言:javascript
复制
class Order {
    static mapping = {
        table "orders"
    }
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10248115

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档