您的位置:首页 > 数据库 > MySQL

hibernate mysql 方言使用的问题

2013-04-08 20:35 148 查看
今天在使用hibernate 自动建表时出现 建表错误 ;现总结一下:

如果mysql数据库版本为5.0以上的 建表类型为type=InnoDB的话 则创建不成功

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name = "hibernateProperties" >
<props >
<!--
这里注意mysql的方言 当为 MySQL5InnoDBDialect 表示支持mysql5.0以上版本 自动创建的表 类型为engine=InnoDB
如果为MySQLInnoDBDialect 表示支持mysql5.0以下的版本 自动创建的表类型为 type=InnoDB
请注意自己的mysql数据库版本 是否与方言匹配

-->
<prop key = "hibernate.dialect" > org.hibernate.dialect.MySQL5InnoDBDialect </prop >
<prop key = "hibernate.show_sql" > true </prop >
<prop key = "hibernate.format_sql" > true </prop >
<prop key = "hibernate.hbm2ddl.auto" > update </prop >
</props >
</property >
<property name="configLocations">
<list>
<value>classpath:hibernate.cfg.xml</value>
</list>
</property>

</bean>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  hibernate mysql 方言