码迷,mamicode.com
首页 > 数据库 > 详细

hibernate4连接mysql自动创建表之错误

时间:2016-05-28 20:38:43      阅读:237      评论:0      收藏:0      [点我收藏+]

标签:

我在学习Hibernate的过程中,遇到了这样一个错误:JUnit测试通过,但是数据库中却没有创建一个表,控制台的错误信息如下:

HHH000388: Unsuccessful: create table t_user (user_id bigint not null auto_increment, card_number varchar(30), card_type varchar(20), company_name varchar(200), email varchar(100), gender varchar(100) not null, identity varchar(20), job_name varchar(60), mobile varchar(30) not null, password varchar(100) not null, real_name varchar(100) not null, primary key (user_id)) type=InnoDB

2014-11-10 10:27:10,749 ERROR (org.hibernate.tool.hbm2ddl.SchemaUpdate:237) - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘type=InnoDB‘ at line 14

2014-11-10 10:27:10,756 ERROR (org.hibernate.tool.hbm2ddl.SchemaUpdate:236) - HHH000388: Unsuccessful: create table t_word (word_id bigint not null auto_increment, content longtext not null, create_date datetime, modify_date datetime, title varchar(100) not null, author_id bigint, primary key (word_id)) type=InnoDB

2014-11-10 10:27:10,763 ERROR (org.hibernate.tool.hbm2ddl.SchemaUpdate:237) - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘type=InnoDB‘ at line 9

2014-11-10 10:27:10,767 ERROR (org.hibernate.tool.hbm2ddl.SchemaUpdate:236) - HHH000388: Unsuccessful: create table t_wordreply (reply_id bigint not null auto_increment, content longtext not null, reply_date datetime, replier_id bigint, word_id bigint, primary key (reply_id)) type=InnoDB

 

可以看到自后都是type=InnoDB,网上搜索了之后,原来是type=InnoDB 是5.0之前使用的,我的数据库是5.5的

这个时候需要把hibernate中mysql的方言改一下,

原来的:hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect

改成:hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect

 

hibernate4连接mysql自动创建表之错误

标签:

原文地址:http://www.cnblogs.com/565261641-fzh/p/5538191.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!