一、数据库方言配置,根据不一样数据库版本,以及使用的数据库,选择合适的方言mysql
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>spring
二、配置文件中使用了create-drop属性,数据库表其实已经建立,只是又被删除了: sql
<property name="hbm2ddl.auto">create-drop</property> 只要把create-drop替换为create或update便可 数据库
三、默认的数据库类型错误。 ide
把mysql中my.ini文件中配置的 MyISAM 变成 INNODB,代码以下: spa
# The default storage engine that will be used when create new tables when hibernate
default-storage-engine=INNODB orm
四、若是在spring里面集成hibernate3,配置文件中每行的末尾必定不能有空格it
<property name="hibernateProperties"> table
<value>
hibernate.dialect=org.hibernate.dialect.MySQLDialect//注意这些地方没有空格
hibernate.hbm2ddl.auto=update//注意这些地方没有空格
hibernate.show_sql=false//注意这些地方没有空格
hibernate.format_sql=false//注意这些地方没有空格
</value>
</property>
五、hbm实体类配置文件中定义的元素含有sql的关键字
例如: <property name="name"></property>
<property name="birthday"></property>
<property name="from"></property> 代码中含有"from"关键字.