关于hibernate.hbm2ddl.auto为update时无法在数据库自动创建表

hibernate.hbm2ddl.auto的配置是为我们自动创建数据库表,具体配置在hibernate.cfg.xml文件中。hibernate.cfg.xml的配置我们可以参照官方文档来配置,当我们配置完想使用 **<property name="hibernate.hbm2ddl.auto">update</property>** 来帮我们自动创建数据库表时,会出现 :Table 'hibernate.xxx' doesn't exist问题。

问题的原因其实是mysql的方言设置不正确:<property name="dialect">,此属性的设置与MySQL的版本有关系,即:

MySQL5.5及以上版本:org.hibernate.dialect.MySQL5InnoDBDialect,

5.5以下是org.hibernate.dialect.MySQLInnoDBDialect,具体的配置应该已Hibernate官方说明为准。

 

猜你喜欢

转载自blog.csdn.net/weixin_41809206/article/details/88788511