一、數據庫方言配置,根據不一樣數據庫版本,以及使用的數據庫,選擇合適的方言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"關鍵字.